The exercise will be marked out of 10, and is worth 5% of your total grade.
Late submissions will be penalized 2.5 marks per day late or part thereof.
Exercise details:
You will be implementing a CircularBuffer class and a program using it, with both conforming to the definitions in the labex3.h header file below.
All of your code is to be in a single file, named labex3.C, which includes and uses the labex3.h file.
I will be using my own copy of labex3.h for compiling and testing your code, and deriving a class from your CircularBuffer class, so make sure it conforms exactly to the specifications.
The CircularBuffer class
The program that uses it
// labex3.h #ifndef LABEX3_H #define LABEX3_H #include <string> using namespace std; // implement a queue using a circular buffer class CircularBuffer { protected: int bufSize; // the size of the array int itemCount; // the number of currently enqueued items int frontIndx; // the array position of the front item int backIndx; // the array position of the back item string* buffer; // the allocated array of strings public: // the default size of the array static const int DefaultSize = 5; // allocates an array of the specified size, // and initializes all the protected fields CircularBuffer(int size = DefaultSize); // deallocate the array ~CircularBuffer(); // add the string to the back of the queue, // adjusting back and wrapping around if necessary // return true if successful, false otherwise bool enqueue(string s); // copy out the string from the front of the queue, // adjusting front and wrapping around if necessary // return true if successful, false otherwise bool dequeue(string &s); // print the items currently in the queue, // from front to back, // displaying one string per line void print(); }; // all text strings entered by the user will be limited // to this size PLUS a null terminator const int MaxTextLen = 255; // the permitted user commands for the application enum Command { QuitCmd = 'Q', // exit the program EnqueCmd = 'E', // enter a text string and enqueue it DequeCmd = 'D', // dequeue a text string and display it PrintCmd = 'P' // print the currently enqueued items // from the (current) front to back }; #endif |
Recommended development sequence As always, I advise you follow a well-thought out sequence of development steps in completing the exercise. The details are being left up to you for this lab.
Submission mechanism
All the code must be in a single file this time, labex3.C,
(correct spelling and capitalization
is essential for the submission to work correctly).
To submit the assignment, cd to the directory that contains your labex3.C file and type the following command:
/home/faculty/wesselsd/bin/submit 161 labex3.C
Marking guidelines:
Marks will be based on:
Code standards:
The submission must follow the code standards for labex2,