Advertisement
IceJade

components.h (lab3)

Feb 20th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #ifndef Components_H
  2. #define Components_H
  3.  
  4. #include <string>
  5.  
  6. class Connection {
  7. public:
  8. Connection();
  9. Connection(Connection& c);
  10. virtual ~Connection();
  11.  
  12. virtual void setValue(double value);
  13. virtual double getValue();
  14.  
  15. private:
  16. double value;
  17. };
  18.  
  19. class Component {
  20. public:
  21. Component(std::string& name, Connection& a, Connection& b);
  22. virtual ~Component();
  23.  
  24. std::string& nameCounter(std::string name);
  25. virtual void update(double time_unit);
  26. virtual double getU();
  27. virtual double getI();
  28. Connection* getA();
  29. Connection* getB();
  30. std::string& getName();
  31.  
  32. private:
  33. Connection* a;
  34. Connection* b;
  35. std::string name;
  36. };
  37.  
  38.  
  39. class Battery : public Component {
  40. public:
  41. Battery(double voltage, Connection& p, Connection& n);
  42. Battery(std::string name, double voltage, Connection& p, Connection& n);
  43.  
  44. void update(double time_unit);
  45.  
  46. private:
  47. double v;
  48. };
  49.  
  50. class Resistance : public Component {
  51. public:
  52. Resistance(double resistance, Connection& a, Connection& b);
  53. Resistance(std::string name, double resistance, Connection& a, Connection& b);
  54.  
  55. void update(double time_unit);
  56. double getI();
  57.  
  58. private:
  59. double r;
  60. };
  61.  
  62.  
  63. class Capacitance : public Component {
  64. public:
  65. Capacitance(double fahrad, Connection& p, Connection& n);
  66. Capacitance(std::string name, double fahrad, Connection& p, Connection& n);
  67.  
  68. void update(double time_unit);
  69. double getI();
  70.  
  71. private:
  72. double c;
  73. double l;
  74. };
  75.  
  76.  
  77.  
  78. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement