Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * KIT101 Assignment 2
- *
- * Wabbit Season -- Organiser Class
- *
- * @author ???
- * @version ???
- *
- * Stage Reached: ???
- */
- import java.util.Scanner;
- public class WabbitSeason {
- // Final instance variables
- // Non-final instance variables
- private boolean tracing = false;
- private boolean isRabbit;
- private ToonBot tb;
- private Scanner scanner;
- private String Target, input;
- private int shotsTaken = 0;
- public WabbitSeason() {
- // constructor body
- tb = new ToonBot(false);
- scanner = new Scanner(System.in);
- setTracing(true);
- tb.setTracing(true);
- }
- public void explain() {
- // method body
- System.out.println("Wabbit Season! You have to track down and recapture a cartoon animal.");
- }
- public void play()
- {
- // method body
- explain();
- boolean playAgain = true;
- while (playAgain) {
- System.out.print("\nWould you like to track down a Rabbit or a Duck? ");
- Target = scanner.next();
- int area = tb.getCurrentArea();
- tb.newGame(isRabbit);
- boolean gameOver = false;
- while (gameOver == false)
- {
- System.out.println("You are tracking " + tb.getTarget());
- Result near = tb.targetNear();
- switch(near) {
- case NEAR:
- System.out.println("You are in area " + tb.getCurrentArea());
- System.out.println("To your north is: " + tb.nextArea('n') + ". To your east is: " + tb.nextArea('e') + ". To your south is: " + tb.nextArea('s') + ",and to your west is: " + tb.nextArea('w'));
- System.out.println("You have hit your target " + tb.getShotCount() + " times " + "and shot a dart into the wrong area " + shotsTaken++ + " times");
- System.out.println("\nYou can hear movement nearby.");
- break;
- case FAR:
- System.out.println("You are in area " + tb.getCurrentArea());
- System.out.println("To your north is: " + tb.nextArea('n') + ". To your east is: " + tb.nextArea('e') + ". To your south is: " + tb.nextArea('s') + ",and to your west is: " + tb.nextArea('w'));
- System.out.println("You have hit your target " + tb.getShotCount() + " times " + "and shot a dart into the wrong area " + shotsTaken++ + " times");
- break;
- case ENRAGED:
- System.out.println("You are still enraged and not able to pay attention to your surroundings.");
- break;
- }
- System.out.print("\nPlease choose from (W)alk, (S)hoot, (R)eset, or (Q)uit: ");
- input = scanner.next();
- if (input.equalsIgnoreCase("w"))
- {
- System.out.println("You chose " + input);
- System.out.print("\nWhich area would you like to walk into? ");
- int areaToMove = scanner.nextInt();
- Result r = tb.tryWalk(areaToMove);
- switch(r) {
- case SUCCESS:
- break;
- case ENRAGED:
- break;
- case FAILURE:
- break;
- case IMPOSSIBLE:
- break;
- }
- }
- else if (input.equalsIgnoreCase("s"))
- {
- System.out.println("you chose " + input) ;
- }
- else if (input.equalsIgnoreCase("r"))
- {
- tb.newGame(isRabbit);
- }
- else if (input.equalsIgnoreCase("q"))
- {
- gameOver = true;
- }
- }
- System.out.println("\nWould you like to play Wabbit Season again (y/n)?");
- input = scanner.nextLine();
- if (input == "y")
- {
- playAgain = true;
- }
- else
- {
- playAgain = false;
- System.out.print("\nThanks for playing Wabbit Season");
- }
- }
- }
- public void setTracing(boolean onOff) {
- tracing = onOff;
- }
- public void trace(String message) {
- if (tracing) {
- System.out.println("WabbitSeason: " + message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement