/** * A class that represents a Mountain space * on the Hyrule Map. * @version .05 * @author Tarsem S. Purewal Jr. */ public class Mountain implements MapSpace { /** * This is a default constructor for the Mountain class. * It simply calls the super class's constructor. */ public Mountain() { super(); } /** * This method defines what happens when Link lands on * a mountain space. A third of the time of the time, Link is damaged by * losing his balance. A third of the time he finds food. * @param link a reference to the character that lands on the mountain space */ public void onLanding(Link link) { int num = generator.nextInt(6); System.out.println("You are in the mountains of Hyrule. The air is thin up here."); //the cases are organized so the probabilities work out //properly switch(num) { case 1: System.out.println("You have come across an orchard of apples!"); System.out.println("Health +3"); link.heal(3); break; case 2: System.out.println("Another weary mountain climber offers you food."); System.out.println("Health +2"); link.heal(2); break; case 3: System.out.println("You have lost your grip and fallen! Luckily, you land on your feet."); System.out.println("Health -3"); link.damage(3); break; case 4: System.out.println("You tripped!"); System.out.println("Health -5"); link.damage(5); break; default: //do nothing }//end switch } /** * This method defines what happens when Link leaves * a mountain space * @param link a reference to the character that just left the mountain */ public void onLeaving(Link link) { System.out.println("You continue onward, through the mountains..."); return; } /** * This method returns the name of the * space. * @return the string "Mountain" */ public String getName() { return "Mountain"; } }