Lab Assignment #3

Due Wednesday, July 29 at the beginning of class

Got questions? Check out the FAQ for this assignment.

This lab assignment tests your knowledge of constructors, destructors, copy-constructors, pointers, and dynamic memory allocation and deallocation. In this assignment, you will implementing and testing a new ADT called a String. The class will be implemented using a dynamic array. You will need to implement several String operations as shown below in the specification of the String class:

class String
{
  public:
    String(void);
    String(char* str);
    ~String(void);
    String(const String& otherString);

    void Set(char* str);
    void Set(const String& otherString);
    void Reverse(void);
    String ReverseNew(void) const;
   
    Boolean isEqual(String otherString) const;
    Boolean isGreater(String otherString) const;
    void Display(Boolean NewLine) const;
   
    int countChars(void) const;
    int countChars(char letter) const;

  private:
    char* string;
};
This specification is in a file called mystring.h. The reason it's not named string.h is because there is already a string.h header file in the standard library and I don't want there to be any confusion. You can get mystring.h from my home directory on PCC's AIX system. (/home/inst/mmead/) It is posted on the class web pages as well. You can access this lab page from the outline at www.pacifier.com/~mmead/cs162/outline.html.

Details


Additional Information

To compile the files on the AIX system into an executable called lab3 you can use this on the command line (assuming your driver code is called driver3.cpp):

xlC -o lab3 driver3.cpp string.cpp
If you are not using the Unix system at PCC, you will have to find out how to compile your programs on the machine you are using. As in all programs you write, you should use meaningful identifier names, and the code must be well commented and consistently formatted. Your functions must have appropriate declarations and detailed header comments must explain the purpose of the function, and describe any inputs and/or outputs. Variables should be declared local to the function they are used in. No global variables are allowed, although global constants are permitted.

Instructions for Submitting Lab #3 (From the syllabus)
Homework is due at the beginning of class. The paper copy is due in class and any e-mailed portion is due before the time class begins. Late assignments will not be accepted. It is better to hand in an incomplete assignment than none, since partial credit will be liberally given. If either the hard copy or email copy is not turned in, the assignment is considered late. Repeat: No late assignments will be accepted. 25% percent of the grade on a homework assignment is based on programming style, comments, clarity, and documentation. This means that even if you turn in a program that runs perfectly, you can expect a grade no higher than a C if you fail to adhere to good programming standards. Remember, partial credit will be awarded for incomplete assignments.

When you email your assignment, the subject line must indicate the class and assignment number. I don't want to accidentally file it with other mail because I didn't know it was a programming lab assignment for this class. You can email it easier from UNIX with the following command:

mail -s "subject" user@computer < filename
For example, to mail the third lab assignment, you would do this:

mail -s "CS162 - Lab #3" mmead@pacifier.com < string.cpp
If you are using a mail system other than this one on UNIX, you will have to figure out how to send me your file. The subject line must be as above and the program code must be plain text in the body of the message (NO attachments.) It won't be accepted otherwise.

If you mail a second version of your program, only that one will be retained. The previous version will be discarded. You shouldn't make a habit of submitting more than one. You should make sure the one you submit is the one you want graded.

Paper copy
You must submit a paper copy of both your string.cpp file and your driver code.

Email portion
You must submit via email only your string.cpp file. DO NOT email the driver code.

Academic Honesty
All assignments must be done individually and each student is expected to submit only original work. You may discuss the problem with other students, but you may not discuss the solution with another student. Any student that permits another student to copy or in any way use his/her work will also be considered guilty of cheating. Any person that violates these requirements will receive an F for the course and a letter will be sent to the head of the CS department. There are no second chances. Note that the instructor may ask any student to explain his/her program verbally.


Back to Outline