Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Device{
  6. protected:
  7. bool PoweredOn;
  8. int DeviceID;
  9. string Manufacturer;
  10. public:
  11. Device(bool p, int i, string c):PoweredOn(p), DeviceID(i), Manufacturer(c)
  12. {cout << "Konstruktor Device" << endl;}
  13. virtual ~Device(){cout << "Destruktor Device" << endl;}
  14. void Turn(){
  15. if(PoweredOn==0){
  16. PoweredOn = 1;
  17. }
  18. else{
  19. PoweredOn = 0;
  20. }
  21. }
  22. void virtual ConnectDisconnect()=0;
  23. };
  24.  
  25. class USBDevice: public virtual Device{
  26. protected:
  27. float USBStandard;
  28. bool Connected1;
  29. public:
  30. USBDevice(float a=0, bool b = 0, bool p = 0, int i = 0, string c = "Kingston" ):USBStandard(a), Connected1(b), Device(p,i,c){
  31. cout << "Konstruktor USBDevice" << endl;}
  32. virtual ~USBDevice(){cout << "Destruktor USBDevice" << endl;}
  33. virtual void ConnectDisconnect(){
  34. if(Connected1==0){
  35. cout << "USB uredjaj nije spojen." << endl;}
  36. else{
  37. cout << "USB uredjaj je spojen." << endl;}}
  38. };
  39.  
  40. class NetworkDevice: public virtual Device{
  41. protected:
  42. float NetworkStandard;
  43. bool Connected2;
  44. public:
  45. NetworkDevice(float e=0, bool d=0, bool p=0, int i=0, string c="Linksys"):NetworkStandard(e), Connected2(d), Device(p,i,c){
  46. cout << "Konstruktor NetworkDevice" << endl;}
  47. virtual ~NetworkDevice(){cout << "Destruktor NetworkDevice" << endl;}
  48. virtual void ConnectDisconnect(){
  49. if(Connected2==0){
  50. cout << "Network uredjaj nije spojen." << endl;}
  51. else{
  52. cout << "Network uredjaj je spojen." << endl;}}
  53. };
  54.  
  55. class WirelessAdapter: public NetworkDevice, public USBDevice{
  56. protected:
  57. int NumberOfAntennas;
  58. int gain;
  59. public:
  60. WirelessAdapter(int z, int y, float a=0, bool b=0, float e=0, bool d=0, bool p=0, int i=0, string c="Adata"):NumberOfAntennas(z), gain(y), USBDevice(a,b), NetworkDevice(e,d), Device(p,i,c)
  61. {cout << "Konstruktor WirelessAdapter" << endl;}
  62. virtual ~WirelessAdapter(){cout << "Destruktor WirelessAdapter" << endl;}
  63. virtual void ConnectDisconnect(){
  64. if(Connected1==0){
  65. USBDevice::ConnectDisconnect();}
  66. if(Connected2==0){
  67. NetworkDevice::ConnectDisconnect();}}
  68. void status(){
  69. cout << "Broj USB uredjaja:" << Connected1 << endl;
  70. cout << "Broj Network uredjaja:" << Connected2 << endl;}
  71. };
  72.  
  73. int main(){
  74. WirelessAdapter Zenga(2, 1, 2.0, true, 802.11, true, false, 505, "Toshiba");
  75. Zenga.status();
  76. Zenga.ConnectDisconnect();
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement