CSE 373 Winter 2005
Homework #1
Anagram Tester
January 6, 2005
Due:
electronically Thursday, Jan. 13, 8:00 pm; paperwork at beginning of
class Friday.
Objectives
- Get your Java juices flowing with a small program that involves
Strings, lists, interfaces, multiple classes.
- Get your algorithmic juices flowing by designing algorithms to
solve non-trivial problems.
- Work through any problems with using the software tools in the
labs and/or your own computers.
- Work through any problems with our system for collecting and
checking homework.
Description
Remember the World Capitals puzzle from NPR? In this homework you
will design and implement solutions to two related problems.
Specifically, you will write
- a method which checks whether two words are anagrams of each other
- a method which checks to see if a word has any anagrams in a
dictionary of words
In addition, you need to write a test method for one of these, and a
short main method (given).
Most of the specification details can be gleaned by studying the code
and comments in the starter code provided.
In particular, there
is an interface called IAnagramChecker. You must write a Java
class class AnagramChecker which implements this interface (in the
technical sense, using the implements keyword). Also
complete the class called AnagramTester.
You must use the
exact names for classes and methods as specified in those
files. You cannot declare a constructor unless it takes
zero arguments. You cannot create additional .java files.
You may not modify IAnagramChecker (you can't turn it in). None
of your methods should require any user input of any kind.
You can have additional helper methods as needed. You can define
additional classes but only if they are internal to the specified .java
files.
The test method testIsAnagram that you are asked to write
deserves a little more discussion. This method should be able to
determine whether any implementation of isAnagram is
correct. In other words, it's not good enough if testIsAnagram
seems to work OK given your version of isAnagram. If I gave
you a
completely different implementation of isAnagram, your testIsAnagram
should be able to determine whether or not that version is correct.
Note that AnagramTester is not a JUnit class. We will use
JUnit in the course, but not just yet.
You are not required to turn in any test method for findAnagrams.
Nevertheless, writing such a method can only help you!
Turn in:
Electronically: two .java files: AnagramChecker.java and AnagramTester.java.
Details of how the electronic turn-in works will be available later.
On paper: printouts of the two .java files. Plus: a short report
which
- describes your algorithms briefly, in English.
- reports on whether you feel (both) your methods work correctly,
and why you feel that way.
- a brief discussion of how efficient isAnagram is.
You do not have to be very formal.
Grading
Most of the grading points will come from
- Correctness of the two algorithms
- Accuracy of the test method
- Efficiency and elegance of the solution
- Following instructions and specifications
- Programming practice (style, comments, etc.)
- The report
Good luck and have fun!
Notes
If you have questions along the way, either about the assignment or how
to do things, feel free to discuss it on the Message Board. Just
don't give away code, or any crucial aspects of the solution.
Where applicable, write your code to be reusable and modifiable.
In a later homework, you might in fact have an opportunity to reuse or
modify code from this one...