Instructions
Practice Problems
Pair Programming Assignment
Problem 1: Circular Data
Problem 2: Designing Mutable Lists
Version: 5.2.1

Assignment 6: Circular Data; State Change

Goals: Practice working with circularly referential data, state change.

PARTNER CHANGE: We forgot to change the partners during the lab. Find a new partner, and email the instructor with your names. If you do not let me know by Sunday evening who is you new partner, I will assign you a partner.

Instructions

The names of the projects and some of the project files must be exactly the same as specified in the assignment. Failure to do so makes it impossible for the graders to run your submission and results in immediate loss of at least 50% of the homework credit.

Make sure you follow the style guidelines for code indentation.

You will submit this assignment by the deadline using the Web-CAT submission system.

With each homework you will also submit your log file named pairxxx.txt where you replace xxx with your pair number.

On top of every file you submit you will have the names of both partners, and the pair number. You loose at least two points for the failure to do so.

The .txt file will be the log of your work on this assignment. Each log entry will have data and time, who was present (one or both of the partners) and a short comment decribing what you were working on.

Due Date: Friday, October 19th, 9:59 pm.

Practice Problems

Work out these problems on your own. Save them in an electronic portfolio, so you can show them to your instructor, review them before the exam, use them as a reference when working on the homework assignments.

Work out the problem we have started in the lectures, dealing with a list of books, where each book can have multiple authors.

Pair Programming Assignment

Problem 1: Circular Data

In this problem we will model a university registrar system.

Note 1: Most of these methods require several helper methods. At least half of the grade for this homework will be assessing the design of these helpers – whether you truly follow the rule one task = one method.

Note 2: All of these methods (except canMeet), are defined only to affect a change in the registrar system. Design your tests carefully. At least one half of the grade for this homework will be assessing the design and implementation your tests for these methods.

Note 3: Did you notice that the above two criteria cover two halves of the grade for the homework? Well, there is some wiggle room, but we really want you to understand how important these two issues are (i.e., helpers and testing).

Problem 2: Designing Mutable Lists

Start a new project HW6-Lists for this problem and import the files from Lists.zip available from the assignment page. You should have three files: Node.java, LoS.java, and LinkedListExamples.java.

The example files show how to design a mutable list by having a special node (a sentinel) that marks the end of the list, so that the empty list has at least one entry, though this entry has no useful data. When we insert into the list (or remove items from it), we change the list.

The LoS and Node classes represent a collection of Strings organized as a list. Instead of having two different classes for the empty list and for nonempty list, we have a class that represents a Node in a list (similar to our Cons class that contained the data and a link to the next item), and a subclass that represents the end of the list (a sentinel). An LoS list always contains exactly one Node. If the list is empty, this Node is our special sentinel node. Each node then links to the the remaining items in the list, except for the las sentinel node that does not link to anything.

The following pictures illustrate the structure of an empty linked list and a linked list after we added three Strings, "abc", "def", and "ghi":

+------+

| LoS  |

+------+  +----------+

| node |->| Sentinel |

+------+  +----------+

          | ""       |

          | null     |

          +----------+

 

+------+

| LoS  |

+------+  +-------+    +-------+    +-------+    +----------+

| node |->|  Node | +->|  Node | +->|  Node | +->| Sentinel |

+------+  +-------+ |  +-------+ |  +-------+ |  +----------+

          | "abc" | |  | "def" | |  | "ghi" | |  | ""       |

          | next  |-+  | next  |-+  | next  |-+  | null     |

          +-------+    +-------+    +-------+    +----------+