Untitled
unknown
plain_text
a year ago
1.8 kB
5
Indexable
#include <iostream> using namespace std; class App { public: App(int d=0) { download = d; } ~App(){}; int getDownload() { return download; } void increaseDownload() { ++download; } private: int download; }; class JJBox:public App{ public: // default constructor is necessary JJBox(int d = 0):App(d){ song = 5 * getDownload(); } int getsongs(){ return song; } void update(){ song = 5 * getDownload(); } private: int song; }; class Nosebook:public App{ public: // default constructor is necessary Nosebook(int d = 0):App(d){ Friend = 3 * getDownload() + 5; } int getFriend(){ return Friend; } void update(){ Friend = 3 * getDownload() + 5; } private: int Friend; }; void main_block(){ int JB_volume , NB_friend; cin >> JB_volume >> NB_friend; JJBox jjbox(JB_volume); Nosebook nosebook(NB_friend); int action; while(1){ cin >> action; switch(action){ case 1: jjbox.increaseDownload(); break; case 2: nosebook.increaseDownload(); break; case 3: jjbox.increaseDownload(); nosebook.increaseDownload(); break; case 4: jjbox.update(); break; case 5: nosebook.update(); break; } if(action == -1) {return;} cout << "JJBox now has " <<jjbox.getsongs() << " songs." << "\n"; cout << "NoseBook now has " << nosebook.getFriend() << " friends." << "\n"; cout << "==========" << "\n"; } return; }
Editor is loading...
Leave a Comment