Homework Assignment 1

Writing a Simple Class


CS 2530
Intermediate Computing


Due: Thursday, September 6, at 8:00 AM


Introduction

This assignment asks you to implement a small class that is part of a larger object-oriented program. You will implement a new MemoDatabase class for the MemoPad program that we have discussed over the first two weeks.

If you have not done so yet, download the code file for Session 1. This zip file contains a directory with all of the files of the MemoPad program. To "unzip" this file, use the unzip command at your Unix or MS-DOS shell prompt, or double-click on the file icon itself.

Among the files you will find there is a default implementation of the MemoDatabase interface, named DefaultMemoDatabase. You will write a new class to use in place of my class.

Here are some Java-specific items that might help you with the assignment:

You can read more about Java strings and the messages they respond to in the documentation for the class.

Designing good methods in Java is similar to designing good functions and procedures in Ada and Python. Use helper methods to eliminate duplication and to make code easier to write. Declare any helper methods you write to be private, as they are details of your implementation.

And, of course, all instance variables are private.

You may do this assignment at the Unix command line or use Dr. Java running on your favorite operating system, whichever you prefer. If you would like some help with Dr. Java, let me know.



Tasks

  1. Write a class that implements the MemoDatabase interface.

    Your class should use a Java array (or arrays) to store its information, rather than a hashtable. This will give you a chance to learn some new Java without having to learn about an entirely new kind of data structure.

    Keep in mind that a Java array does not know how many items it contains; it knows only how many items it can hold.

    Give your class a good name that reflects something about how it does its job.


  2. Change the MemoPad class to use your database class.

    Change the one line in the MemoPad class that creates the database to make an instance of your class instead.

You do not need to modify any other class in the program, or the MemoPadin any other way. I will use your two classes with original versions of all the other files when I test them.

Extra Credit: Store the data in such a way that your database provides O(log n) performance on look-ups and no worse than O(n) performance on insertions.



Deliverables

By the due date and time, submit the files

Be sure that your submission follows all homework submission requirements.



Eugene Wallingford ..... wallingf@cs.uni.edu ..... August 30, 2012