C Sc 127B Project 10: public class OrderedMap<K extends Comparable<K>, V>
This
project is to completed individually. Due Date:
Tuesday, 17-April @ 10:00pm
Create a new project and add
these files: BankAccount.java, OrderedMapTest.java and
OrderedMap.java (link
corrected at 3:00 pm, 11-April). To OrderedMap.java that
already has the inner MapNode class with the put and size
methods, implement the additional
methods listed below. Make sure you write extensive tests for all methods. We will run your code against
our tests that check for all situations.
// Return all keys in this OrderedMap as an ArrayList of Ks.
// The first element in the ArrayList must be key that precedes all other keys.
// The last element must be key that follows all other keys.
public ArrayList<K> keysAsList()
// Return all values in this OrderedMap as an ArrayList of Vs.
// The first value in the ArrayList (at get(0)) must be the one with
// the key that precedes all other keys. The last element in the
// ArrayList must be the one with the key that follows all other keys.
public ArrayList<V> valuesAsList()
//If the key exists, remove the key/value mapping from the collection and
// return true. If the key is not found return false and leave the collection // in the same state. Precondition: K implements Comparablepublic boolean remove(K keyOfelementToRemove)
You may develop
your own algorithm or use this remove algorithm that
will be discussed during Friday's lecture (complete the remove method last)
Grading Criteria (100 points): Subject to Change
____ / +4 You have a unit test that tests all methods by calling all
methods at least once
____ / +16 You thoroughly tested all methods three
methods, especially remove (12pts)
____ / +4 You turned in an Eclipse project with all methods that
compile and are a reasonable attempt
____ / +10 Good Style and Design, Unanticipated error which is defined as
Your class
has your name and a description of its purpose.
Used
intention-revealing names (meaningful identifiers).
Used
consistent spacing/indentation (format all code with Source > Format).
Class names begin
with an UpperCase letter
All method
and variable names begin with a lowerCase letter
Placed one
blank line between methods
Used local
variables when appropriate and instance variables when appropriate
There are no unanticipated errors or breeches of good style or design