Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎notes‎ > ‎

2017-10-31

posted Oct 30, 2017, 8:21 PM by Konstantinovich Samuel
Goal: Give in to your hatred... of Java. 

IMPORTANT: 
You cannot hide a public inherited method by making it private. 
-Since all derived classes are expected to function as the base class when storing them in variables, this is not allowed. 

Example: 
Player has a public method attack()
Wizard extends Player. 

Player a = new Wizard();
a.attack();//Wizard cannot make this private, or it would break this functionality.




public class OrderedSuperArray extends SuperArray{

  /*constructor initializes an empty List*/
  public OrderedSuperArray(){
    //Complete this.
  }

  /*call the proper add.*/
  public void add(int index, String value){
    add(value);
  }

  /*Write this method and any
    appropriate helper methods.*/
  public boolean add(String value){
    //add to the correct spot.
    //you may still use super.add(index,value)
    return true;
  }


}
Comments