/** * A class that represents a Desert space * on the Hyrule Map. * @version .05 * @author Tarsem S. Purewal Jr. */ public class Desert implements MapSpace { /** * This is a default constructor for the Desert class. * It simply calls the super class's constructor. */ public Desert() { super(); } /** * This method defines what happens when Link lands on * a desert space. Half of the time, Link is damaged by * the desert sun. A third of the time he finds water. * @param link a reference to the character that lands on the desert space */ public void onLanding(Link link) { int num; System.out.println("You are in the desert. The sun is high overhead. It's hot!"); num = generator.nextInt(6); //The switch statement is organized so the probabilities //work out properly switch(num) { case 0: case 1: case 2: System.out.println("The sweltering heat is causing you great distress!"); System.out.println("Health -10"); link.damage(10); break; case 3: case 4: System.out.println("You have arrived at a small pool of water!"); System.out.println("Health +5"); link.heal(5); break; case 5: System.out.println("You need to get out of the heat soon!"); break; default: //do nothing break; } } /** * This method defines what happens when Link leaves * a desert space * @param link a reference to the character that just left the desert */ public void onLeaving(Link link) { System.out.println("You continue on, trudging through the desert..."); return; } /** * This method returns the name of the * space. * @return the string "Desert" */ public String getName() { return "Desert"; } }