2016-10-27 HW

posted Oct 27, 2016, 6:51 AM by Samuel Konstantinovich   [ updated Oct 27, 2016, 9:24 AM ]
SUPER ARRAY!!!!!

Write the basic SuperArray Class:  (4 methods to fill in below)

public class SuperArray{
  private int[] data;
  private int size;
  
  //0
//constructor make an empty superArray should make size 0,
  //but the data capacity 10.

  public int size(){
    return size;
  }

  //1
/**add the value n to the next available slot in the superArray.
 *this will change the size. This function should always work
 *And will resize the SuperArray if needed./*
public void add(int n){ }

  //2
/**Resize the data, by making a new array, then copying over elements, use this as your data.
*/
private void grow(){ } //3
   /**format the super array like this :   [ 1, 3, 6, 8, 23, 99, -4, 5] 
    *commas between... square bracket start/end and no comma at end.*/
  public String toString(){
  }

  //4
    /**format the super array like this :   [ 1, 8, 23, 99, -4, 5, _, _, _, _]   
    *(capacity is 10, but only 6 are used)
    *commas between... square bracket start/end and no comma at end.
    *unused slots should be printed as _ (underscores) */
  public String toStringDebug(){
  }
}
Comments