Advertisement
Guest User

keks

a guest
Oct 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class X{
  8. protected:
  9.     int key;
  10. public:
  11.     X(const int &i){
  12.         key = i;
  13.         cout << "constructor X" << endl;
  14.     }
  15.  
  16.     ~X(){
  17.         cout << "Destructor X" << endl;
  18.     }
  19. };
  20.  
  21. class Y{
  22. protected:
  23.     int key;
  24. public:
  25.     Y(const int &i){
  26.         key = i;
  27.         cout << "constructor Y" << endl;
  28.     }
  29.  
  30.     ~Y(){
  31.         cout << "Destructor Y" << endl;
  32.     }
  33. };
  34.  
  35. class Z{
  36. protected:
  37.     int key;
  38. public:
  39.     Z(const int &i){
  40.         key = i;
  41.         cout << "constructor Z" << endl;
  42.     }
  43.  
  44.     ~Z(){
  45.         cout << "Destructor Z" << endl;
  46.     }
  47. };
  48.  
  49. class A :public X, public Y, public Z{
  50. private:
  51.     int key;
  52. public:
  53.     A(const int &i) :X(i + 1), Y(i + 2), Z(i + 3){
  54.         key = X::key + Y::key + Z::key;
  55.     }
  56.     int getKey(){
  57.         return key;
  58.     }
  59. };
  60.  
  61.  
  62. class Computer{
  63. protected:
  64.     string _name;
  65.     int _ram;
  66.     string _gpuName;
  67. public:
  68.     Computer(const string name, const int ram, const string gpuName){
  69.         _name = name;
  70.         _ram = ram;
  71.         _gpuName = gpuName;
  72.         cout << "Constructor Computer" << endl;
  73.     }
  74.     ~Computer(){
  75.         cout << "Destructor Computer" << endl;
  76.     }
  77.    
  78.     string getName(){
  79.         return _name;
  80.     }
  81.  
  82.     int getRAM(){
  83.         return _ram;
  84.     }
  85.  
  86.     string getGpuName(){
  87.         return _gpuName;
  88.     }
  89.  
  90.     void setName(string Name){
  91.         _name = Name;
  92.     }
  93.  
  94.     void setRam(int Ram){
  95.         _ram = Ram;
  96.     }
  97.  
  98.     void setRam(string gpuName){
  99.         _gpuName = gpuName;
  100.     }
  101.  
  102.     virtual void PrintInfo(){
  103.         cout << "name: " << _name << "| ram: " << _ram << "| gpuname: " << _gpuName << endl;
  104.     }
  105. };
  106.  
  107.  
  108. class Server{
  109. protected:
  110.     int _cores;
  111.     int _channels;
  112.     string _specs;
  113. public:
  114.     Server(const int cores, const int channels, const string specs){
  115.         _cores = cores;
  116.         _channels = channels;
  117.         _specs = specs;
  118.         cout << "Constructor Server" << endl;
  119.     }
  120.  
  121.     ~Server(){
  122.         cout << "Destructor Server" << endl;
  123.     }
  124.  
  125.     int _getCores(){
  126.         return _cores;
  127.     }
  128.  
  129.     int _getChannels(){
  130.         return _channels;
  131.     }
  132.    
  133.     string _getSpecs(){
  134.         return _specs;
  135.     }
  136.  
  137.     void setCores(int cores){
  138.         _cores = cores;
  139.     }
  140.  
  141.     void setChannels(int channels){
  142.         _channels = channels;
  143.     }
  144.  
  145.     void setSpecs(string specs){
  146.         _specs = specs;
  147.     }
  148.  
  149.     virtual void PrintInfo(){
  150.         cout << "cores: " << _cores << "| channels: " << _channels << "| specs: " << _specs << endl;
  151.     }
  152. };
  153.  
  154. class PComputer:public Computer{
  155. protected:
  156.     bool _sound;
  157.     string _soundCard;
  158.     string _mouseType;
  159.  
  160. public:
  161.     PComputer(const string Name, const int ram, const string gpuName, bool sound, string soundCard, string mouseType){
  162.         _name = Name;
  163.         _ram = ram;
  164.         _gpuName = gpuName;
  165.         _sound = sound;
  166.         _soundCard = soundCard;
  167.         _mouseType = mouseType;
  168.  
  169.         cout << "Constructor PComputer" << endl;
  170.     }
  171.     ~PComputer(){
  172.         cout << "Destructor PComputer" << endl;
  173.     }
  174.  
  175.     bool getSound(){
  176.         return _sound;
  177.     }
  178.  
  179.     string getSoundCard(){
  180.         return _soundCard;
  181.     }
  182.  
  183.     string getMouseType(){
  184.         return _mouseType;
  185.     }
  186.  
  187.     void setSound(bool sound){
  188.         _sound = sound;
  189.     }
  190.  
  191.     void setSoundCard(string soundCard){
  192.         _soundCard = soundCard;
  193.     }
  194.  
  195.     void setMouseType(string mouseType){
  196.         _mouseType = mouseType;
  197.     }
  198.  
  199.     virtual void PrintInfo(){
  200.         Computer::PrintInfo();
  201.         cout << "sound: " << _sound << "| soundcard: " << _soundCard << "| mousetype: " << _mouseType << endl;
  202.     }
  203.  
  204. };
  205.  
  206. class Notebook : public Computer{
  207. protected:
  208.     double _diagonal;
  209.     double _batteryTime;
  210.     double _weight;
  211.  
  212. public:
  213.     Notebook(const string Name, const int ram, const string gpuName, const double diagonal, const double batteryTime, const double weight){
  214.         _name = Name;
  215.         _ram = ram;
  216.         _gpuName = gpuName;
  217.         _diagonal = diagonal;
  218.         _batteryTime = batteryTime;
  219.         _weight = weight;
  220.  
  221.         cout << "Constructor NoteBook" << endl;
  222.     }
  223.  
  224.     ~Notebook(){
  225.         cout << "Destructor NoteBook" << endl;
  226.     }
  227.  
  228.     double getDiagonal(){
  229.         return _diagonal;
  230.     }
  231.  
  232.     double getBatteryTime(){
  233.         return _batteryTime;
  234.     }
  235.  
  236.     double getWeight(){
  237.         return _weight;
  238.     }
  239.  
  240.     void setDiagonal(double diag){
  241.         _diagonal = diag;
  242.     }
  243.  
  244.     void setBatteryTime(double btime){
  245.         _batteryTime = btime;
  246.     }
  247.  
  248.     void setWeight(double weight){
  249.         _weight = weight;
  250.     }
  251.  
  252.     virtual void PrintInfo(){
  253.         Computer::PrintInfo();
  254.         cout << "diagonal: " << _diagonal << "| batteryTime: " << _batteryTime << "| weight: " << _weight << endl;
  255.     }
  256. };
  257.  
  258. class MoveableServer : public Server, public Notebook{
  259. protected:
  260.     bool _internetAccess;
  261.     string _serverName;
  262.     string _osName;
  263.  
  264. public:
  265.     MoveableServer(const int cores, const int channels, const string specs, const string Name, const int ram, const string gpuName, const double diagonal, const double batteryTime, const double weight, bool internetAccess, string serverName, string osName){
  266.         _cores = cores;
  267.         _channels = channels;
  268.         _specs = specs;
  269.  
  270.         _name = Name;
  271.         _ram = ram;
  272.         _gpuName = gpuName;
  273.         _diagonal = diagonal;
  274.         _batteryTime = batteryTime;
  275.         _weight = weight;
  276.  
  277.         _internetAccess = internetAccess;
  278.         _serverName = serverName;
  279.         _osName = osName;
  280.  
  281.         cout << "Constructor MoveableServer" << endl;
  282.     }
  283.  
  284.     ~MoveableServer(){
  285.         cout << "Destructor MoveableServer" << endl;
  286.     }
  287.  
  288.     bool getIntAccess(){
  289.         return _internetAccess;
  290.     }
  291.  
  292.     string getServName(){
  293.         return _serverName;
  294.     }
  295.  
  296.     string getOsName(){
  297.         return _osName;
  298.     }
  299.  
  300.     void setIntAccess(bool IA){
  301.         _internetAccess = IA;
  302.     }
  303.  
  304.     void setServName(string servName){
  305.         _serverName = servName;
  306.     }
  307.  
  308.     void setOsName(string osName){
  309.         _osName = osName;
  310.     }
  311.  
  312.     virtual void PrintInfo(){
  313.         Server::PrintInfo();
  314.         Notebook::PrintInfo();
  315.         cout << "internet Access: " << _internetAccess << "| servName: " << _serverName << "| OS name: " << _osName << endl;
  316.     }
  317. };
  318. int main()
  319. {
  320.     Computer *ptrComputer = new Computer("Keks", 16, "NVIDIA");
  321.  
  322.     Server *ptrServer = new Server(4, 16, "super slow");
  323.  
  324.     PComputer *ptrPComputer = new PComputer("PKeks", 8, "AMD", true, "super sound", "trackball");
  325.  
  326.     Notebook *ptrNotebook = new Notebook("NoteKeks", 4, "AMD_note", 8.3, 20, 3);
  327.  
  328.     MoveableServer *ptrMvServer = new MoveableServer(8, 16, "super fast", "keksMoveableServer", 32, "nvidia moveable", 0, 30.5, 8, true, "keksServerName", "Linux");
  329.  
  330.     ptrComputer->PrintInfo();
  331.  
  332.     ptrServer->PrintInfo();
  333.  
  334.     ptrPComputer->PrintInfo();
  335.  
  336.     ptrNotebook->PrintInfo();
  337.  
  338.     ptrMvServer->PrintInfo();
  339.     /*
  340.     A *obj = new A(4);
  341.     cout << obj->getKey() << endl;
  342.     delete obj;
  343.     */
  344.     return 0;
  345. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement