1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
class Article {
char* _code;
char* _name;
double _price;
int _amount;//in warehouse
public:
Article() {
_code = NULL;
_name = NULL;
_price = 0;
_amount = 0;
}
Article(char* c, char* n, double c, int k) {
_code = new char[strlen(c) + 1];
strcpy_s(_code, strlen(c) + 1, c);
_name = new char[strlen(n) + 1];
strcpy_s(_name, strlen(n) + 1, n);
_price = c;
_amount = k;
}
~Article() {
delete[] _code;
delete[] _name;
_code = NULL;
_name = NULL;
}
void operator-= (int amo) {
_amount -= amo;
if (_amount < 0) _amount = 0;
}
Article operator++() {//preincrement
_amount += 1;
return *this;
}
Article operator++(int) {//postincrement
_amount += 1;
return *this;
}
Article operator--() {//predecrement
if(_amount<0) _amount -= 1;
return *this;
}
Article operator--(int) {//postdecrement
if (_amount<0) _amount -= 1;
return *this;
}
bool operator==(Article& other) {
return strcmp(_code, other._code);
}
friend ostream& operator<<(ostream&, Article&);
ostream& operator<<(ostream& COUT, Article& obj) {
cout << "Code: " << obj._code << endl << "Name: " << obj._name << endl << "Price: " << obj._price << endl << "Warehouse units: " << obj._amount<<endl;
return COUT;
}
class CheckItem {
Article _article;
int* _amount;//on the bill
public:
CheckItem() {
*_amount = 0;
}
CheckItem(int* a, char* c, char* n, double p, int amo):_article(c,n,p,amo) {
_amount = new int;
*_amount = *a;
}
~CheckItem() {
delete _amount;
_amount = NULL;
}
};
class Check {
int _checkNr;
CheckItem _items[100];
int _itemsNr;
double _subTotal;
double _Total;
bool _printed;
public: // this part of code is not finished
Check(int brc) {
_checkNr = brc;
}
};
|