calc.h

 #ifndef CALC_H
#define CALC_H
#include <iostream>
using namespace std;
#include <iomanip>

#define null 0
#define True 1
#define False 0

int FindLength(char *chStringLegnthOf) {
int nFindLengthCount = 0;
while (chStringLegnthOf[nFindLengthCount] != 0)
++nFindLengthCount;
return nFindLengthCount;
}
double StringToInt(char *chString) {
for (int nStringCount = 0; chString[nStringCount] != 0; ++nStringCount) {
if (chString[nStringCount] < 48 || chString[nStringCount] > 57)
return null;
}
double *dString = new double[FindLength(chString)];
for (int nStringCount = 0; chString[nStringCount] != 0; ++nStringCount)
dString[nStringCount] = chString[nStringCount] - 48;
for (int nStringCount = 0; nStringCount <= FindLength(chString); ++nStringCount)
for (int nStringCount2 = nStringCount; nStringCount2 <= FindLength(chString) - 2; ++nStringCount2)
dString[nStringCount] *= 10;
double dNumber = 0;
for (int nStringCount = 0; nStringCount != FindLength(chString); ++nStringCount)
dNumber += dString[nStringCount];
return dNumber;
}
bool NumbersOnly(char *chStringVal) {
for (int i = 0; chStringVal[i] != 0; ++i)
if (chStringVal[i] < 48 || chStringVal[i] > 57)
return False;
return True;
}
class STRING {
public:
STRING(char *chStringValue2 = "") { chStringValue = chStringValue2; }
~STRING() { chStringValue = 0; }
friend istream& operator>>(istream &in, STRING &Svalue) {
in >> Svalue.chStringValue;
return in;
}
friend bool operator==(STRING &Svalue, char *chStringValue2) {
if (FindLength(Svalue.chStringValue) == FindLength(chStringValue2)) {
for (int i = 0; Svalue.chStringValue[i] != 0 || chStringValue2[i] != 0; ++i)
if (Svalue.chStringValue[i] != chStringValue2[i])
return False;
return True;
}
return False;
}
char& operator[](const int nIndex) { return chStringValue[nIndex]; }
operator char*() { return chStringValue; }
private:
char *chStringValue;
};
class Math {
public:
Math() {
m_nNumberStorage = new double[10];
m_chStringNameStorage = new char*[11];
for (int i = 0; i <= 10; ++i) {
m_nNumberStorage[i] = 0.0;
m_chStringNameStorage[i] = " ";
}
m_nNumberStorage[11] = 0;
}
char* GetStorageName(int nLocation) { return m_chStringNameStorage[nLocation]; }
double GetData(int nLocation) { return m_nNumberStorage[nLocation]; }
void SetData(int nLocation, double nNumber) { m_nNumberStorage[nLocation] = nNumber; }
void Save(int nLocation, double nNumber, char *chStringSaveID) {
if (nLocation <= 10 && nNumber != 0 || chStringSaveID != 0) {
m_nNumberStorage[nLocation] = nNumber;
m_chStringNameStorage[nLocation] = chStringSaveID;
}
}
void DisplayData() {
cout << "Location:\t\tName:\t\t\tData:\n";
for (int i = 0; m_nNumberStorage[i] != 0 || i <= 10; ++i) {
if (i + 1 < 10)
cout << " ";
cout << i + 1 << "\t\t\t" << m_chStringNameStorage[i] << "\t\t";
if (FindLength(m_chStringNameStorage[i]) <= 7)
cout << "\t";
cout << m_nNumberStorage[i] << endl;
}
}
void Delete(int nLocation) {
m_nNumberStorage[nLocation] = 0;
m_chStringNameStorage[nLocation] = " ";
for (int i = nLocation; i < 10; ++i) {
m_nNumberStorage[i] = m_nNumberStorage[i + 1];
m_chStringNameStorage[i] = m_chStringNameStorage[i + 1];
}
m_nNumberStorage[10] = 0;
m_chStringNameStorage[10] = " ";
}
private:
double *m_nNumberStorage;
char **m_chStringNameStorage;
};
#endif

Project Homepage: