Last active
August 29, 2015 14:10
-
-
Save mariusmg2/e84c6ea9e35329ee661e to your computer and use it in GitHub Desktop.
Revisions
-
mariusmg2 revised this gist
Nov 30, 2014 . 1 changed file with 23 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ // Version2, pastebin: http://pastebin.com/raw.php?i=Q4A83hdM [OUTDATED] // clang++ -Wall -O3 -g tema2poo.c++ -o poo -std=c++14 #include <iostream> #include <string> @@ -21,11 +22,11 @@ public: Phone(void): producer(""), color(""), weight(0), dimension(0) {}; virtual ~Phone(void) {}; string getProducer(void) const; string getColor(void) const; int getWeight(void) const; int getDimension(void) const; virtual void displayInfo(void) const; }; class mobilePhone: public Phone { @@ -35,9 +36,9 @@ public: mobilePhone(string &producer, string &color, int &weight, int &dimension, string &operatingSystem, string &displayType): Phone(producer, color, weight, dimension), operatingSystem(operatingSystem), displayType(displayType) {}; ~mobilePhone(void) {}; string getOS(void) const; string getDisplayType(void) const; virtual void displayInfo(void) const; }; class wirePhone: public Phone { @@ -48,57 +49,57 @@ public: wirePhone(string &producer, string &color, int &weight, int &dimension, string &type, unsigned int ringtoneVolume): Phone(producer, color, weight, dimension), type(type), ringtoneVolume(ringtoneVolume) {}; ~wirePhone(void) {}; string getType(void) const; unsigned int getRingtoneVolume(void) const; virtual void displayInfo(void) const; }; string Phone::getProducer(void) const { return (string)producer; } string Phone::getColor(void) const { return (string)color; } int Phone::getWeight(void) const { return (int)weight; } int Phone::getDimension(void) const { return (int)dimension; } void Phone::displayInfo(void) const { cout << endl << "Producer: " << producer; cout << endl << "Color: " << color; cout << endl << "Weight: " << weight; cout << endl << "Dimension: " << dimension; } string mobilePhone::getOS(void) const { return (string)operatingSystem; } string mobilePhone::getDisplayType(void) const { return (string)displayType; } void mobilePhone::displayInfo(void) const { Phone::displayInfo(); cout << endl << "Operating system: " << operatingSystem; cout << endl << "Display type: " << displayType << endl; } string wirePhone::getType(void) const { return (string)type; } unsigned int wirePhone::getRingtoneVolume(void) const { return (unsigned int)ringtoneVolume; } void wirePhone::displayInfo(void) const { Phone::displayInfo(); cout << endl << "Type: " << type; cout << endl << "Ringtone volume: " << ringtoneVolume << endl; -
mariusmg2 revised this gist
Nov 30, 2014 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Version2, pastebin: http://pastebin.com/raw.php?i=Q4A83hdM [OUTDATED] #include <iostream> #include <string> @@ -20,7 +20,7 @@ public: producer(producer), color(color), weight(weight), dimension(dimension) {}; Phone(void): producer(""), color(""), weight(0), dimension(0) {}; virtual ~Phone(void) {}; string getProducer(void); string getColor(void); int getWeight(void); @@ -104,7 +104,7 @@ void wirePhone::displayInfo(void) { cout << endl << "Ringtone volume: " << ringtoneVolume << endl; } Phone *readPhone(int phtype) { string producer, color, operatingSystem, displayType, type; int weight, dimension; unsigned int ringtoneVolume; @@ -130,7 +130,7 @@ Phone *insert(int phtype) { int main(int argc, char **argv) { list<Phone*> phones; // Linked list of 'Phone' objects (actually pointers to 'Phone' objects). int opt = {0}; string aux; while(1) { @@ -145,10 +145,10 @@ int main(int argc, char **argv) { switch(opt) { case 1: phones.push_back(readPhone(1)); break; case 2: phones.push_back(readPhone(2)); break; case 3: for(auto i : phones) { @@ -188,3 +188,4 @@ int main(int argc, char **argv) { return 0; } -
mariusmg2 revised this gist
Nov 26, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -177,7 +177,7 @@ int main(int argc, char **argv) { break; case 6: for(auto i : phones) { delete i; } phones.clear(); return 0; -
mariusmg2 revised this gist
Nov 26, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // Version2, pastebin: http://pastebin.com/raw.php?i=Q4A83hdM #include <iostream> #include <string> #include <list> -
mariusmg2 created this gist
Nov 25, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,188 @@ #include <iostream> #include <string> #include <list> using std::cin; using std::cout; using std::string; using std::endl; using std::list; using std::getline; class Phone { private: string producer, color; int weight, dimension; public: Phone(string &producer, string &color, int &weight, int &dimension): producer(producer), color(color), weight(weight), dimension(dimension) {}; Phone(void): producer(""), color(""), weight(0), dimension(0) {}; ~Phone(void) {}; string getProducer(void); string getColor(void); int getWeight(void); int getDimension(void); virtual void displayInfo(void); }; class mobilePhone: public Phone { private: string operatingSystem, displayType; public: mobilePhone(string &producer, string &color, int &weight, int &dimension, string &operatingSystem, string &displayType): Phone(producer, color, weight, dimension), operatingSystem(operatingSystem), displayType(displayType) {}; ~mobilePhone(void) {}; string getOS(void); string getDisplayType(void); virtual void displayInfo(void); }; class wirePhone: public Phone { private: string type; unsigned int ringtoneVolume; public: wirePhone(string &producer, string &color, int &weight, int &dimension, string &type, unsigned int ringtoneVolume): Phone(producer, color, weight, dimension), type(type), ringtoneVolume(ringtoneVolume) {}; ~wirePhone(void) {}; string getType(void); unsigned int getRingtoneVolume(void); virtual void displayInfo(void); }; string Phone::getProducer(void) { return (string)producer; } string Phone::getColor(void) { return (string)color; } int Phone::getWeight(void) { return (int)weight; } int Phone::getDimension(void) { return (int)dimension; } void Phone::displayInfo(void) { cout << endl << "Producer: " << producer; cout << endl << "Color: " << color; cout << endl << "Weight: " << weight; cout << endl << "Dimension: " << dimension; } string mobilePhone::getOS(void) { return (string)operatingSystem; } string mobilePhone::getDisplayType(void) { return (string)displayType; } void mobilePhone::displayInfo(void) { Phone::displayInfo(); cout << endl << "Operating system: " << operatingSystem; cout << endl << "Display type: " << displayType << endl; } string wirePhone::getType(void) { return (string)type; } unsigned int wirePhone::getRingtoneVolume(void) { return (unsigned int)ringtoneVolume; } void wirePhone::displayInfo(void) { Phone::displayInfo(); cout << endl << "Type: " << type; cout << endl << "Ringtone volume: " << ringtoneVolume << endl; } Phone *insert(int phtype) { string producer, color, operatingSystem, displayType, type; int weight, dimension; unsigned int ringtoneVolume; cout << endl << endl << "Producer: ", cin >> producer; cout << "Color: ", cin >> color; cout << "Weight: ", cin >> weight; cout << "Dimension: ", cin >> dimension; if(phtype == 1) { cout << "Operating System: ", cin >> operatingSystem; cout << "Display type: ", cin >> displayType; return (Phone*)(new mobilePhone(producer, color, weight, dimension, operatingSystem, displayType)); } else if(phtype == 2) { cout << "Type: ", cin >> type; cout << "Ringtone volume: ", cin >> ringtoneVolume; return (Phone*)(new wirePhone(producer, color, weight, dimension, type, ringtoneVolume)); } return NULL; } int main(int argc, char **argv) { list<Phone*> phones; // Linked list of 'Phone' objects (actually pointers to 'Phone' objects). int opt = 0; string aux; while(1) { cout << endl << endl << "1) Adauga telefon mobil."; cout << endl << "2) Adauga telefon fix."; cout << endl << "3) Afiseaza telefoanele."; cout << endl << "4) Cauta un telefon (dupa producator)."; cout << endl << "5) Sterge un telefon (dupa producator)."; cout << endl << "6) Iesire."; cout << endl << endl << "Optiunea aleasa: ", cin >> opt; switch(opt) { case 1: phones.push_back(insert(1)); break; case 2: phones.push_back(insert(2)); break; case 3: for(auto i : phones) { cout << "\n\n----------------------------|"; i->displayInfo(); cout << "----------------------------|"; } break; case 4: cout << "\nNumele producatorului: ", cin >> aux; for(auto i : phones) { if(i->getProducer() == aux) { i->displayInfo(); } } break; case 5: cout << "\nNumele producatorului: ", cin >> aux; for(auto i : phones) { if(i->getProducer() == aux) { phones.remove(i); cout << endl << "Producatorul " << i->getProducer() << " a fost sters.\n"; break; } } break; case 6: for(auto i : phones) { delete[] i; } phones.clear(); return 0; default: continue; } } return 0; }