Guest User

Untitled

a guest
May 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. class Pin
  2. {
  3.     bool wartosc;
  4. public:
  5.     void ustaw (bool test);
  6.     bool zwroc () { return wartosc; }
  7.     Pin () { wartosc = 0; }
  8.     Pin (bool w) : wartosc(w) {}
  9.     friend class Sygnal;
  10.     friend class AND;
  11.     //friend class OR;
  12.     //friend class XOR;
  13.     //friend class NOT;
  14.     //friend class NOR;
  15.     //friend class NAND;
  16. };
  17.  
  18.  
  19. void Pin::ustaw (bool test)
  20. {
  21.     wartosc = test;
  22. }
  23.  
  24. class Bramka : public Abstrakcyjna
  25. {
  26.     static unsigned int LiczbaWszystkichBramek;
  27.     string bramka; bool w1, w2, wyjscie;
  28. public:
  29.     static string sukces () {string ob= "Stworzono obiekt o nazwie: "; return ob; }
  30.     void reset () { w1=0, w2=0; }
  31.       friend class AND;
  32.       //friend class OR;
  33.       //friend class XOR;
  34.       //friend class NOT;
  35.       //friend class NOR;
  36.       //friend class NAND;
  37. };
  38.  
  39.  
  40.  
  41.  
  42. class AND : public Bramka
  43. {
  44.  
  45.     static unsigned int id;
  46.     //string bramka;            <-------- Zdeklarowane w klasie bramka
  47. public:
  48.     static unsigned int _id() ;
  49.     string opis_bramki ();
  50.     AND () {}
  51.     AND (Pin _var1, Pin _var2);         //      <-------- Zdeklarowane w klasie Pin
  52.     string _nazwa ();  
  53.     bool wyjscie () { return w1 && w2; }    //      <-------- Zdeklarowane w klasie bramka
  54. };
  55. unsigned int AND::id=0;
  56. unsigned int AND::_id () {id++; return id;}
  57. string AND::_nazwa()
  58. {
  59.     bramka=sukces()+bramka;     //      <-------- Zdeklarowane w klasie bramka
  60.     return bramka; 
  61. }
  62. string AND::opis_bramki()
  63. {
  64.     ostringstream ss;
  65.     ss << id;
  66.     string str = ss.str();
  67.     string a="AND "; string b=str;
  68.     string w=a+b;
  69.     return w;      
  70. }
  71. AND::AND (Pin _var1, Pin _var2)
  72. {
  73.     w1=_var1.wartosc;
  74.     w2=_var2.wartosc;
  75.     id=_id ();
  76.     bramka=opis_bramki ();      //          <-------- Zdeklarowane w klasie bramka
  77.     sukces();
  78. }
Add Comment
Please, Sign In to add comment