i would appreciate if somebody actually helps me, every time i make a thread someone always jus yells at me for breaking rules
# Implement the Stack class' constructor and destructor.
# Implement the following public methods:
* void enqueue (VALUE value);
Add the object specified by the value parameter onto the end of the queue.
* VALUE dequeue ();
Removes first value from the queue and returns it.
* VALUE front ();
Returns the first value from the queue, but does not remove it.
*
VALUE rear ();
Returns the last value from the queue, but does not remove it.
o Implement the following public "helper" methods:
+ int getSize()
Returns the number of elements in the array.
+ bool isEmpty()
Returns true if the list is empty. Otherwise it returns false
+ bool isFull()
Returns true if the list is full. Returns false to otherwise.
#define STACK_H_
03
04 template<class TYPE>
05 class Queue
06 {
07 private:
08 class Node
09 {
10 public:
11 TYPE value;
12 Node *next;
13
14 Node(TYPE theValue, Node *existingList)
15 {
16 value = theValue;
17 next = existingList;
18 }
19 };
20
21 int size;
22 Node *front;
23 Node *rear;
24
25 public:
26 class QueueFullException {};
27 class QueueEmptyException {};
28
29 Queue()
30 {
31 }
32
33 TYPE dequeue()
34 {
35 if (!isEmpty())
36 {
37 }
38 else
39 throw new QueueEmptyException();
40 }
41
42 void enqueue(TYPE newValue)
43 {
44 if (!isFull())
45 {
46 }
47 else
48 throw new QueueFullException();
49 }
50
51 TYPE getFront()
52 {
53 TYPE result;
54
55 if (!isEmpty())
56 {
57 }
58 else
59 throw new QueueEmptyException();
60
61 return result;
62 }
63
64 TYPE getRear()
65 {
66 TYPE result;
67
68 if (!isEmpty())
69 {
70 }
71 else
72 throw new QueueEmptyException();
73
74 return result;
75 }
76
77 int getSize()
78 {
79 }
80
81 bool isEmpty()
82 {
83 }
84
85 bool isFull()
86 {
87 }
88 };
89
90 #endif /* STACK_H_ */

New Topic/Question
This topic is locked



MultiQuote







|