Group PAG
/
PAG-CourseWork-NicksEdits
Minor fixes
Fork of Coursework by
Queue.cpp@43:4ddc392dd0cc, 2017-05-04 (annotated)
- Committer:
- pburtenshaw
- Date:
- Thu May 04 12:55:16 2017 +0000
- Revision:
- 43:4ddc392dd0cc
- Parent:
- 42:4e0a96b52e65
queue updatd but many errors - suspected missing colon or bracket?
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pburtenshaw | 42:4e0a96b52e65 | 1 | #include "Queue.h" |
pburtenshaw | 42:4e0a96b52e65 | 2 | |
pburtenshaw | 43:4ddc392dd0cc | 3 | Queue::Queue(int i){ |
pburtenshaw | 43:4ddc392dd0cc | 4 | front = 0; |
pburtenshaw | 43:4ddc392dd0cc | 5 | back = 0; |
pburtenshaw | 43:4ddc392dd0cc | 6 | isFull = false; |
pburtenshaw | 43:4ddc392dd0cc | 7 | storage = new Measure[i]; |
pburtenshaw | 43:4ddc392dd0cc | 8 | } |
pburtenshaw | 43:4ddc392dd0cc | 9 | |
pburtenshaw | 43:4ddc392dd0cc | 10 | Queue::Queue(){ |
pburtenshaw | 42:4e0a96b52e65 | 11 | front = 0; |
pburtenshaw | 42:4e0a96b52e65 | 12 | back = 0; |
pburtenshaw | 43:4ddc392dd0cc | 13 | isFull = false; |
pburtenshaw | 43:4ddc392dd0cc | 14 | storage = new Measure[maxSize]; |
pburtenshaw | 43:4ddc392dd0cc | 15 | } |
pburtenshaw | 43:4ddc392dd0cc | 16 | |
pburtenshaw | 43:4ddc392dd0cc | 17 | void Queue::push(Reading r){ |
pburtenshaw | 43:4ddc392dd0cc | 18 | //if it is full then the front must move. if front is max then it must become 0 |
pburtenshaw | 43:4ddc392dd0cc | 19 | if (isFull == true){ |
pburtenshaw | 43:4ddc392dd0cc | 20 | if (front == maxSize-1){ |
pburtenshaw | 43:4ddc392dd0cc | 21 | front = 0; |
pburtenshaw | 43:4ddc392dd0cc | 22 | } |
pburtenshaw | 43:4ddc392dd0cc | 23 | else{ |
pburtenshaw | 43:4ddc392dd0cc | 24 | front = front +1; |
pburtenshaw | 43:4ddc392dd0cc | 25 | } |
pburtenshaw | 43:4ddc392dd0cc | 26 | |
pburtenshaw | 42:4e0a96b52e65 | 27 | } |
pburtenshaw | 43:4ddc392dd0cc | 28 | back = back +1; |
pburtenshaw | 43:4ddc392dd0cc | 29 | storage[back] = r; |
pburtenshaw | 43:4ddc392dd0cc | 30 | //otherwise the queue is full |
pburtenshaw | 43:4ddc392dd0cc | 31 | else{ |
pburtenshaw | 43:4ddc392dd0cc | 32 | |
pburtenshaw | 43:4ddc392dd0cc | 33 | } |
pburtenshaw | 43:4ddc392dd0cc | 34 | } |
pburtenshaw | 43:4ddc392dd0cc | 35 | void Queue::read(int nR){// where nR is the number to read, if REAL ALL is typed then the method will be called by something like queue.read(Queue.count). |
pburtenshaw | 43:4ddc392dd0cc | 36 | if (front>back){ |
pburtenshaw | 43:4ddc392dd0cc | 37 | for( int a = back; a >=0; a = a - 1 ) { |
pburtenshaw | 43:4ddc392dd0cc | 38 | //print or cout? do until end of loop - think about how to loop over |
pburtenshaw | 43:4ddc392dd0cc | 39 | } |
pburtenshaw | 43:4ddc392dd0cc | 40 | } |
pburtenshaw | 43:4ddc392dd0cc | 41 | for( int a = maxSize-1; a >front; a = a + 1 ) { |
pburtenshaw | 43:4ddc392dd0cc | 42 | //print or cout? do until end of loop - think about how to loop over |
pburtenshaw | 43:4ddc392dd0cc | 43 | } |
pburtenshaw | 43:4ddc392dd0cc | 44 | |
pburtenshaw | 43:4ddc392dd0cc | 45 | |
pburtenshaw | 42:4e0a96b52e65 | 46 | |
pburtenshaw | 43:4ddc392dd0cc | 47 | } |
pburtenshaw | 43:4ddc392dd0cc | 48 | void Queue::deleteRecords(int nD){ //as above but nD is number to delete |
pburtenshaw | 43:4ddc392dd0cc | 49 | |
pburtenshaw | 43:4ddc392dd0cc | 50 | |
pburtenshaw | 43:4ddc392dd0cc | 51 | } |