CSCI 202 Homework 2


In this assignment you will design a very simple abstract data type.

Due dates

This assignment must be submitted to the Moodle submission page for Homework 2 with the name by 11:00 PM on Thursday, 26 January.

Starting the assignment

Find a computer where you can run Java programs under NetBeans. Hopefully, it will be one you use at home.

Your program must be written for the homework2 package. Use the Java class TestDriver to test your class.


Implement an ADT with a Java class name Note in the package homework2 to represent musical notes. For this assignment the notes are going to consist of three pieces of information.

  1. a letter: the characters from 'A' to 'G'
  2. an accidental: the characters 'f', ' ', or 's'
  3. an octave: an integer between -1 and 9

For this first assignment, we are going to take it easy and allow and character to be used an a letter or an accidental and any integer to be used as an octave.

Make all the fields of your ADT private. Make sure that it provides the following accessor methods.

Make sure it contains the following mutator methods.

Your ADT implementation should contain two constructors. One constructor should take three arguments, corresonding to the letter, accidental, and octave, in order. The second constructor should take no arguments and create an object having the letter 'C', the accidental ' ', and the octave 4.