The following guidelines are expected for all homework submissions:
all over the mapon *my* computer or in my editor. USE SPACES INSTEAD. You can set up almost every modern text editor to insert spaces whenever you press the TAB key, or you can simply pound the spacebar.
pair programmingwhich is part of the Extreme Programming software development method. Feel free to collaborate in your pairs as much as you want, doing the entire assignment together.
You will be using the HighArray
class from the textbook for this homework assignment. This class
uses an array and demonstrates insertion, deletion, and location operations. The implementation is not
too difficult. The base class file (Listing 2.3) is on pages 49-50. There is a separate class that
contains the main method for this program, called HighArrayApp
which begins at the bottom of page
50. Your task is to use these two classes to implement the following projects.
HighArray.java
source file. Be sure to use good coding practices
to make your code pretty, artful, and maintainable. You can copy and paste the source code from the
text book,
which will make your life easier.HighArrayApp.java
file in the same way. Compile that source as well, to
make sure there are no errors. NOTE THIS IS A SEPARATE FILE – don't include this code in the
same class file as HighArray.java
, the way it is in the textbook!HighArrayApp.java
source code to make sure there are no errors.HighArrayApp
program to ensure everything works properly.HighArray
class in the HighArray.java
program, add a method
called getMax()
that returns the value of the highest key in the array, or –1 if
the array is empty. Add some code in the main()
method in the HighArrayApp.java
to test this method. You can assume all the keys are positive numbers. Add AT LEAST FIVE
new test cases, which means you will need to add or remove values from the array between calls to the
getMax()
tests.noDups()
method for the HighArray
class of the HighArray.java
program. This method should remove all duplicates from the array. That is, if three items with the key
17
appear in the array, noDups()
should remove two of them. Don’t worry about
maintaining the order of the items. One approach is to first compare every item with all the other items
and then .overwrite any duplicates with a null [or a distinctive value that isn’t used for real keys].
Then remove all the nulls. Of course, the array size must be reduced correctly.