CS 201 - Computer Science I - Fall 2004
Lab 7 - arrays


Loyola College > Department of Computer Science > CS 201 > Labs > Lab 7

Due

Electronic Submission: Monday, November 29 at 11:59pm. Labs submitted one day late will be assessed a 20% penalty. Labs will not be accepted more than one day late.
Write-up and print out: Wednesday, December 1 at the beginning of class

Objectives

Reading

Koffman & Wolz, Sections 5.4 through 5.5

Assignment

Create a class called Dictionary<YourName>. Instances of this class will store lists of words in an array. The class should have the following:

Your class should work with the following test driver. The following code can be downloaded from the file DictionaryTest.java.

public class DictionaryTest
{
    public static void main(String[] args)
    {
        Dictionary english = new Dictionary(10);
        Dictionary german = new Dictionary(10);
        Dictionary shark = new Dictionary(2);
        Dictionary martian = new Dictionary(10);

        english.addWord("eat");
        english.addWord("five");
        english.addWord("swim");

        german.addWord("essen");
        german.addWord("funf");
        german.addWord("schwimmen");

        shark.addWord("eat");
        shark.addWord("swim");

        martian.addWord("swim");
        martian.addWord("eat");
        martian.addWord("five");

        System.out.println("=== TESTING contains ===");
        System.out.println(english.contains("two")); // should be false
        System.out.println(english.contains("funf")); // false
        System.out.println(german.contains("funf")); // true
        System.out.println(german.contains("fork".charAt(0) + "unf")); // true
	
        System.out.println("=== TESTING equals ===");
        System.out.println(english.equals(german)); // false
        System.out.println(english.equals(shark)); // false
        System.out.println(english.equals(english)); // true
        System.out.println(martian.equals(english)); // true
    }
}

Write-up

Begin with an introduction that explains the purpose of the lab. Then describe the methods contains, addWord, and equals. Use specific examples when describing the behavior of the method given different circumstancs. For contains and addWord, you should include at least two examples, and for equals, decribe two examples that return true and two that return false. Use different examples that than those given in DictionaryTest.java. Also describe any situations where your code initially outputted the wrong answer, and what you did to correct the problem. Conclude with any comments or concerns.

This write-up will be graded for quality of writing and use of technical terms. Sophistication of the write-up will also be accessed.

Grading

Submissions

Submit the source code for your Dictionary<LastName1><LastName2> class using the class submission page. Turn in a print out of your code and write-ups in class.