2016-11-02 Extending our superarray!

posted Nov 2, 2016, 6:45 AM by Samuel Konstantinovich   [ updated Nov 3, 2016, 6:11 AM ]
1. Discuss the SuperArray class we all wrote.
2. Discuss the goal of the OrderedSuperArray class.
  -What must be changed?
  -How do we want to change it?
4. Write the class OrderedSuperArray over the next two days: (one lab day, and 2 evenings)

Since Constructors are not inherited:

public OrderedSuperArray()  //-> just call super();

public OrderedSuperArray(int capacity)  //-> just call super();

Do this constructor last:

    public OrderedSuperArray(int [] ary) //-> call super and add all the elements

Methods you need to change:

1. set(int index, int element) : Should this be allowed? Why?  Why not?

    - throw an UnsupportedOperationException

2. add(int index, int element) : Should this be allowed? Why?  Why not?

    - throw an UnsupportedOperationException

3. add (int element) 

    You should write a private method to find the index that you want to add the element to. 

4. Optionally you can make the following methods more efficient:

    indexOf(element)    

    lastIndexOf(element)


Comments