BEST代写-最专业、靠谱的代写

Best代写-最专业、靠谱的代写IT&CS | 留学生作业 |编程代写 | Java | Python | C/C++ | PHP | Matlab | Assignment Project Homework代写

C++代写 | CMPT 225 Summer 2019 Assignment 1

C++代写 | CMPT 225 Summer 2019 Assignment 1

CMPT 225 Summer 2019 Assignment 1 Due 12 June 2019
The CharList class
In this assignment, your task is to implement a doubly-linked list of characters. You are not allowed to use library functions for this task. The class that stores the list should be called CharList, and it should have the following API:
bool empty();
int size();
void insert(char c);
void append(char c);
void insert(char c, char d);
void append(char c, char d);
// is the list empty?
// the number of elements in the list
// inserts the character c at the front of the list
// inserts the character c at the back of the list
// inserts c immediately before the first occurance of d, or // at the end of the list if d does not occur.
// inserts c immediately after the first occurance of d, or // at the end of the list if d does not occur.
void insert(char c, char d, int n);// inserts c immediately before the nth occurance of d, or // at the end of the list if d does not occur n times.
void append(char c, char d, int n); // inserts c immediately after the nth occurance of d, or // at the end of the list if d does not occur n times.
void remove(char c);
void remove(char c, int n);
string toString(); CharList(string s); ~CharList();
// delete the first occurance of character c. Do nothing if // c does not occur.
// delete the nth occurance of c. Do nothing if c does not // occur n times.
// return the list as a string.
// constructor. Initializes the list to the contents of the string. // destructor. Returns all memory in the list.
The constructor takes a string, such as “abc”, and makes a list with the characters of the string in order, such as ‘a’, then ‘b’, then ‘c’. The toString() method does the same in reverse—it constructs a string consisting of the characters of the list, in order.
You may add private member functions and member variables to the API. You may use default argumentsifthatmakesimplementationeasierforyou. YoushouldhaveaCharList.hfileanda CharList.cpp, and you may have any other classes and files that you like.

Testing
We will test your code using a main.cpp that we will not provide you with. To be sure that your code is correct, you should test it yourself. Include with your submission a main.cpp that creates a CharList, applies operations to it, and compares the result of these operations (via toString) with what you expect the result to be. If it is what you expect, print “passed”, and otherwise print “failed” along with the expected result string and the actual result string.
For instance, the following main creates a CharList and tests one function, printing the resulting string form of the CharList:
int main(int argc, char** argv) {
CharList* c = new CharList(“abd”);
c->insert(‘c’, ‘d’);
cout << “result: “ << c.toString() << endl;
}
This code should print: abcd
But you should test all functions, not just one. And test to be sure that functions are inserting at the back of the list when they should. Also, in your submission, only print the line with “passed” or “failed” on it. (During your debugging, you may want to print more.)
Submission
Use CourSys (http://coursys.sfu.ca) for submission of your assignment. You’ll need to create a zip file with your .cpp and .h files in it. Do not include compiled files (any .o files, a.out, or a.exe).

bestdaixie