Minor fixes

Dependencies:   LPS25H hts221

Fork of Coursework by Group PAG

Committer:
noutram
Date:
Thu May 04 14:54:07 2017 +0000
Revision:
44:2b23c7407547
Now builds - Queue was the name of an existing class

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noutram 44:2b23c7407547 1 #include "MyQueue.h"
noutram 44:2b23c7407547 2
noutram 44:2b23c7407547 3
noutram 44:2b23c7407547 4 MyQueue::MyQueue(){
noutram 44:2b23c7407547 5 maxSize = 120;
noutram 44:2b23c7407547 6 front = 0;
noutram 44:2b23c7407547 7 back = 0;
noutram 44:2b23c7407547 8 isFull = false;
noutram 44:2b23c7407547 9 storage = new Reading[maxSize];
noutram 44:2b23c7407547 10 }
noutram 44:2b23c7407547 11
noutram 44:2b23c7407547 12 void MyQueue::push(Reading r){
noutram 44:2b23c7407547 13 //if it is full then the front must move. if front is max then it must become 0
noutram 44:2b23c7407547 14 if (isFull == true){
noutram 44:2b23c7407547 15 if (front == maxSize-1){
noutram 44:2b23c7407547 16 front = 0;
noutram 44:2b23c7407547 17 }
noutram 44:2b23c7407547 18 else{
noutram 44:2b23c7407547 19 front = front +1;
noutram 44:2b23c7407547 20 }
noutram 44:2b23c7407547 21 back = back +1;
noutram 44:2b23c7407547 22 storage[back] = r;
noutram 44:2b23c7407547 23 }
noutram 44:2b23c7407547 24
noutram 44:2b23c7407547 25 //otherwise the MyQueue is full
noutram 44:2b23c7407547 26 else {
noutram 44:2b23c7407547 27
noutram 44:2b23c7407547 28 }
noutram 44:2b23c7407547 29 }
noutram 44:2b23c7407547 30 void MyQueue::read(int nR){// where nR is the number to read, if REAL ALL is typed then the method will be called by something like MyQueue.read(MyQueue.count).
noutram 44:2b23c7407547 31 if (front>back){
noutram 44:2b23c7407547 32 for( int a = back; a >=0; a = a - 1 ) {
noutram 44:2b23c7407547 33 //print or cout? do until end of loop - think about how to loop over
noutram 44:2b23c7407547 34 }
noutram 44:2b23c7407547 35 }
noutram 44:2b23c7407547 36 for( int a = maxSize-1; a >front; a = a + 1 ) {
noutram 44:2b23c7407547 37 //print or cout? do until end of loop - think about how to loop over
noutram 44:2b23c7407547 38 }
noutram 44:2b23c7407547 39 }
noutram 44:2b23c7407547 40
noutram 44:2b23c7407547 41 void MyQueue::deleteRecords(int nD){ //as above but nD is number to delete
noutram 44:2b23c7407547 42
noutram 44:2b23c7407547 43
noutram 44:2b23c7407547 44 }