CSci 2101 Lab 5. Java classes, interfaces, hierarchy.

Tuesday February 28, Friday March 3. Work in pairs.

Part 1: follow-up on the card game

Download a card class and a game class from the google doc folder. Do not use the combination we used in class. Put them together in Eclipse.
Make any necessary changes to get it to work. Clearly document what changes you made (in a separate file; google doc ok).
Also make style changes as you see necessary. Again, explain what you changed and why.
What are the benefits and tradeoffs of working with multiple classes Java classes as a group?

Part 2: linked list: starting code, working as a group

We will start by looking at interfaces examples and the ideas behind a linked list. Then we will start with this starting code for linked list and write a couple of methods as a group.

Part 3, Friday March 3: finishing up linked list class

Start with the work-in-progress code that we wrote in class.

Finish writing and testing linked list class. More specifically:

  1. Write a toString() method that returns a string representation of a linked list. For instance, if the linked list has elements 3, 5, 8 (in this order), the toString should return the string [3, 5, 8]. After you have written the method, you should be able to put your linked list into a System.out.println and use this for debugging of other methods.
  2. Once you get toString() to work, use it to test add.
  3. Once you convince yourself that add works, write and debug get. Don't forget to check for exceptions being thrown.
  4. Carefully read the description of remove in the OurList interface (note that the method is described from the user's standpoint; the way you think about it as an implementor is different -- you don't think of elements in terms of their indices). Write tests for remove in TestOurLinkedList. Think of different cases that you need to consider. Make sure that you can successfully use add and get after removing some of the elements. The quality of your testing will be graded.
  5. Implement remove, one case at a time, and run tests after each modification, even if you know that some tests are going to break.
  6. Once remove is implemented, make sure that your list is tested well; add tests as needed. Also pay attention to the quality of your code: simplify, streamline, and rename your code as needed. Rerun your tests after each change to make sure that nothing is broken.

Eclipse resources:

How to submit:

Send me all your code (CC your group).


CSci 2101 course web site.