Due Date: Thursday of week 04

The following guidelines are expected for all homework submissions:

Problems for Assignment #2

Learning Outcomes: 1) Get used to programming in Python; 2) find out how to use lists and several primitive data types in Python; 3) write test cases using the main method in your source code with lots of test cases; 4) practice adding new methods into an existing program; 5) practice determineing and adding expanded test cases to cover the added methods

You will be using the HighArray.py class from my repo for this homework assignment. The class uses alist and demonstrates insertion, deletion, and location operations. The implementation is not too difficult. The base class file is given to you, along with a basic tester which is a separate file that contains the main method for this program, called HighArrayTest.py. Your task is to use these two classes to implement the following projects.

There is an evaluation rubric in my repo in the homework02 directory that you can use to see what is expected for this assignment. Take a look at it so you won't be surprised by anything.

  1. First, create your HighArray.py source file by navigating to my GitHub repo and then downloading a copy of the file called HighArrayEmpty.py. Rename your copy to be HighArray.py. Be sure to use good coding practices to make your code pretty, artful, professional, and maintainable. Starting with the existing code will make this assignment much easier, but if you would like to do it on your own, I don't want to rain on your parade.
  2. Run that source code to make sure there are no errors. This is always a good idea so that you know the code you're starting with is good. Otherwise, when you add in your own code and get errors, you won't know if those errors are from your code or the starting code.
  3. Create the HighArrayTest.py file in the same way, downloading the initial file from my repo. Run 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 file as HighArray.py!
  4. Once you have both files working, it's time to modify your HighArray.py file.
  5. Edit the HighArrayTest.py file and in the import line at the top, change the from HighArrayEmpty import HighArray to be from HighArray import HighArray. This will make sure the tester will use your copy of the HighArray.py code.
  6. OK, time for some research! Look up how to print the values in a list, then add a function into your HighArray.py code to print the list. Name your function display(). Test it to make sure it displays the values in the list by running the tester.
  7. Now, to the HighArray.py program, add a function called getMax() that returns the value of the highest item in the array, or –1 if the array is empty. Add some code in the main() method in the HighArrayTest.py program to test this function. You can assume all the list indices 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. Also make sure to test on an empty list!
  8. Write a noDupes() function for the HighArray.py class. This method should remove all duplicates from the list. That is, if three items with the value 17 appear in the list, noDupes() should remove two of them. Don't worry about maintaining the order of the items. Feel free to do some further research on this and see if you can find an 'elegant' way to do it. If not, brute force is fine.
  9. Submit both your source code files to your repo. THERE MUST BE TWO PYTHON SOURCE FILES IN YOUR REPO FOR THIS ASSIGNMENT.