Lab Assignment #4

Due Monday, August 10 at the beginning of class

Got questions? Check out the FAQ for this assignment.

This lab assignment tests your knowledge of linked lists and how to perform operations on them. In this assignment, you will be implementing and testing a new ADT called a StrList. From the client's point of view, a StrList is a list of NULL terminated strings. From the implementor's point of view, a StrList is a linked list of Node structs as defined below. You will need to implement several StrList operations as shown below in the specification of the StrList class:

class StrList
{
  public:
    StrList(void);
    void Prepend(const char *item);
    void Display(Boolean separateLine = TRUE) const;
    int getCount(void) const;
    Boolean isEmpty(void) const;
    ~StrList(void);
    void Append(const char *item);
    Boolean isPresent(const char *item) const;
    const char* getItem(int position) const;
    void Remove(const char *item);

  private:
    Node* head;
};
The details of what the functions do can be found in the specification file strlist.h. As a suggestion, I've listed the public member functions in the order that you should implement them. The definition of a Node is as follows and must be included at the top of your implementation file immediately following any #include directives.
struct Node
{
  char word[MAX_LENGTH + 1];
  Node* next;
};
MAX_LENGTH is defined in strlist.h. There is also a driver called driver4.cpp that you can get to help you test your code. You can get strlist.h and the driver code from my home directory on PCC's AIX system. (/home/inst/mmead/) They are accessible from this document also.

Details


Additional Information

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

xlC -o lab4 driver4.cpp strlist.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 #4 (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 fourth lab assignment, you would do this:

mail -s "CS162 - Lab #4" mmead@pacifier.com < strlist.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 your strlist.cpp file.

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

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