miky0123

stack.h

Apr 5th, 2013
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 3;
  6.  
  7. class Stack
  8. {
  9.     private:
  10.         Televize Data[N];
  11.         int pointer;
  12.  
  13.     public:
  14.         Stack();
  15.         bool IsEmpty(Stack &s);
  16.         bool IsFull(Stack &s);
  17.         void Push(Stack &s,Televize t);
  18.         Televize Pop(Stack &s);
  19.  
  20. };
  21.  
  22.  
  23. Stack::Stack()
  24. {
  25.     pointer = 0;
  26. }
  27.  
  28. bool Stack::IsEmpty(Stack &s)
  29. {
  30.     return (pointer == 0);
  31. }
  32.  
  33. bool Stack::IsFull(Stack &s)
  34. {
  35.     return (pointer == N);
  36. }
  37.  
  38. void Stack::Push(Stack &s,Televize t)
  39. {
  40.     if(IsFull(s) != true)
  41.     {
  42.         s.Data[pointer++] = t;
  43.     }
  44.     else
  45.         cout << "\n\nZasobnik je plny!\n\n";
  46. }
  47.  
  48. Televize Stack::Pop(Stack &s)
  49. {
  50.     if(IsEmpty(s) != true)
  51.     {
  52.         return s.Data[--pointer];
  53.     }
  54.     else
  55.         cout << "\n\nZasobnik je prazdny!\n\n";
  56. }
RAW Paste Data