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 86 87 88 89 90 91 92 93
|
#include <iostream>
#include <iomanip>
#include <conio.h>
#define MAX_REC 50
using namespace std;
class Inventory{
public:
Inventory(); // constructor
void addItem(); // lets user input info for bottles
void showSpace(int); // shows occupied/avialble space
void printList(); // prints out a inventory list
private:
string name;
string type;
string size;
};
/////////////////////////////////Def///////////////////////////////////
Inventory::Inventory(){
name = "Random", type = "rum", size = "small",
name = "SKY", type = "vodka", size = "large",
name = "OldTown", type = "wiskey", size = "small";
name = "RumRum", type = "rum", size = "medium";
}
void Inventory::addItem(){
cout << "\nEnter bottle name: "; cin >> name;
cout << "Enter type: "; cin >> type;
cout << "Enter size: "; cin >> size;
if(size == "small"){showSpace(1);}
if(size == "medium"){showSpace(2);}
if(size == "large"){showSpace(3);}
}
void Inventory::showSpace(int num){
static int s = 0;
static int m = 0;
static int l = 0;
switch( num ){
case 1:{
s++;
cout << "\nSmall bottles: " << s << " / " << (60 - s) << endl;
cout << "Medium bottles: " << m << " / " << (40 - m) << endl;
cout << "Large bottles: " << l << " / " << (20 - l) << endl;
} break;
case 2:{
m++;
cout << "\nSmall bottles: " << s << " / " << (60 - s) << endl;
cout << "Medium bottles: " << m << " / " << (40 - m) << endl;
cout << "Large bottles: " << l << " / " << (20 - l) << endl;
} break;
case 3:{
l++;
cout << "\nSmall bottles: " << s << " / " << (60 - s) << endl;
cout << "Medium bottles: " << m << " / " << (40 - m) << endl;
cout << "Large bottles: " << l << " / " << (20 - l) << endl;
} break;
}
}
void Inventory::printList(){
cout << endl;
cout.width(15);
cout.setf(ios::left, ios::adjustfield);
cout << name;
cout.width(8);
cout << type;
cout.width(15);
cout.setf(ios::right, ios::adjustfield);
cout.setf(ios::showpoint);
cout.setf(ios::fixed,ios::floatfield);
cout.precision(2);
cout << size;
}
|