Get help on this challenge

Debugging2


Please read this explanation before attempting debugging challenges.


What the hell? My Java code breaks when I try to run it? What's wrong and how can I fix it?

/**
 * A class that does some stuff
 * @author ynori7 
 */
class Thingy
{
  private int watermelon, cantaloupe;
    
  public Thingy()
  {
    // initialise instance variables with undescriptive names
    watermelon = 0;
    cantaloupe = 0;
  }
	
  public void increaseWatermelon(int thisMuch)
  {
    watermelon += thisMuch;
  }
	
  public void increaseCantaloupe(int thisMuch)
  {
    cantaloupe += thisMuch;
  }

  public String display()
  {
    String disp = "Watermelon: " + watermelon + " Cantaloupe: " + cantaloupe;
    return disp;
  }
}

public class ThingyMain
{
  public static void main(String[] args) 
  {
    Thingy[] thingyLog;
    thingyLog = new Thingy[3];
    
    thingyLog[0].increaseWatermelon(17);
    thingyLog[0].increaseCantaloupe(-3); 
    System.out.println(thingyLog[0].display());
    
    thingyLog[1].increaseWatermelon(13);
    thingyLog[1].increaseCantaloupe(2); 
    System.out.println(thingyLog[1].display());
        
    thingyLog[2].increaseWatermelon(234);
    thingyLog[2].increaseCantaloupe(33); 
    System.out.println(thingyLog[2].display());
  }
}

Downloadable source code can be found here.


You must be logged in to play.



Challenge by ynori7.