Проект по STL "Компьютерный магазин".
Программа должна обрабатывать базу данных компьютеров и комплектующих. Сортировать, выводить по параметрам, ввод,вывод... Объекты класса компьютер содержат ссылки на соответстувующее железо. Удаляешь компьютер - авто удаляется и его железо. Помогите правильно организовать классы, я немного запутался на этом этапе.
Проблема в том как вообще все это организовать и в классах ввода вывода - они должны наследовать от стандартных и самостоятельно понимать ссылка на железо или на компьютер передана.
Примерная схема задумки в приложении.
//Preprocessor// #include <iostream> #include <string> #include <vector> #include <algorithm> #include <conio.h> #include <windows.h> #include <process.h> using namespace std; ////INTERFACE/////// //Menu int menu(){ cls(); cout << "PUT Some key" << endl; cout << "F1 - vvod F2 - vivod vse" << endl; int key; while(1){ key = getch(); switch (key){ case 59: AddHard(); break; case 60: PrintAllHard(); break; } } } ////////////////// ////OBJECTS/////// ////////////////// class apparate{ private: string name; float price; float termo; public: virtual float optim()=0; inline void set_name(string n){ this->name=n; } inline void set_price(float pr){ this->price=pr; } inline void set_termo(float tr){ this->termo=tr; } }; class hardware: public apparate{ private: string type; string descript; float memory; float freq; public: hardware(){ this->freq=9; }; hardware( string t, string d, float m, float f){ this->type=t; this->descript=d; this->memory=m; this->freq=f; } virtual float optim(){ return 0; } inline set_type(string t){ this->type=t; } inline set_desc(string d){ this->descript=d; } inline set_mem(float m){ this->memory=m; } inline set_freq(float f){ this->freq=f; } }; class computer: public hardware{ private: hardware opermem; hardware soundcard; public: }; /////////////////////// /////RULE CLASSES////// /////////////////////// class ioconsole{ private: public: void cls(){ HANDLE hConsole; CONSOLE_SCREEN_BUFFER_INFO csInfo; DWORD dummy; COORD Home={0,0}; hConsole=GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &csInfo); FillConsoleOutputCharacter(hConsole,' ',csInfo.dwSize.X*csInfo.dwSize.Y,Home,&dummy); SetConsoleCursorPosition(hConsole,Home); printf("\nComputer Magazine\n"); printf(" \n"); } void PrintAllHard(hardware &h){ for (int i=1; i<h.size; i++){ h[i].print(); cout << endl; } } void Print(){ cout << type << " - " << descript <<" - " << memory << " - " << freq << endl; } void AddHard(hardware &h){ hardware temp; string temp1; float temp2; cin >> temp1; temp.set_name(temp1); cin >> temp1; temp.set_desc(temp1); cin >> temp2; temp.set_mem(temp2); cin >> temp2; temp.set_freq(temp2); h.push_back(temp); } } class iofile : public iofstream{ } /////////////// /////MAIN////// /////////////// int main(){ hardware temp("vint", "40 gb IDE RAID", 40, 34.4f); vector<hardware> hSpisok; vector<hardware>::iterator hIterator; cout << hSpisok.size()<<endl; return 0; };
Не думай о белой обезьяне.