CLASS PROGRAM- cant edit it /** StarletsWorld class @author: Robyn Gibson & Julian Dermoudy @version: KXT101 Programming & Problem Solving purpose:resources for assignment 2, semester 1, 2007*/import java.util.Random;public class StarletsWorld { public final int MOVE_OK = 11; public final int PHOTOGRAPHED = 21; public final int BORED = 22; public final int NOT_POSSIBLE = -1; public final int PAPARAZZI_FOUND = 23; public final int DOG_LOST = 12; public final char LEFT = 'l'; public final char FORWARD = 'f'; public final char BACKWARD = 'b'; public final char RIGHT = 'r'; private final int NUM_AREAS = 9; private final int[] RIGHT_AREA = {1,2,0,4,5,3,7,8,6}; private final int[] LEFT_AREA = {2,0,1,5,3,4,8,6,7}; private final int[] FORWARD_AREA = {6,7,8,0,1,2,3,4,5}; private final int[] BACKWARD_AREA = {3,4,5,6,7,8,0,1,2}; private final String[] LITTLE_DOGS = {"Tinks","Dinks","Kinks"}; private int currArea; //current location of player private int paparazziPos; //Area where the paparazzi are private int carParkPos; //Area where the car park is found private Random generator; // to use for random placement in shops etc. private boolean tracing; //switch for tracing messages /** constructor instantiates the random number generator */ public StarletsWorld() { generator = new Random(); } /** setUp @param an int, indicates how the seeding is to be done (with param value 0 there is no seeding - stays with default) seeds the random generator */ public void setUp(int num) { if (num != 0) { generator.setSeed(num * 4567); } } /** getNumAreas @return an int, indicates how many areas in the system */ public int getNumAreas() { return NUM_AREAS; } /** newGame @return an int, indicates the starting location (Area) randomly determines location of start (currentArea), carPark, paparazzi NOTE: These 3 positions will always be different */ public int newGame() { int pos; pos = generator.nextInt(NUM_AREAS); currArea = pos; trace("player starts at " + currArea); pos = generator.nextInt(NUM_AREAS); while (pos == currArea) { pos = generator.nextInt(NUM_AREAS); } paparazziPos = pos; trace("paparazzi are at " + paparazziPos); pos = generator.nextInt(NUM_AREAS); while(pos == currArea || pos == paparazziPos) { pos = generator.nextInt(NUM_AREAS); } carParkPos = pos; trace("car park is at " + carParkPos); return currArea; } /** paparazziAdjacent @return a boolean true if paparazzi location is in a Area connected to current */ public boolean paparazziAdjacent() { boolean isClose = false; if ((RIGHT_AREA[currArea ] == paparazziPos) || (FORWARD_AREA[currArea ] == paparazziPos) || (BACKWARD_AREA[currArea ] == paparazziPos) || (LEFT_AREA[currArea ] == paparazziPos) ) { isClose = true; trace("paparazzi are close "); } return isClose; } /** carParkAdjacent @return a boolean true if carPark location is in a Area connected to current */ public boolean carParkAdjacent() { boolean isClose = false; if ((RIGHT_AREA[currArea ] == carParkPos) || (FORWARD_AREA[currArea ] == carParkPos) || (BACKWARD_AREA[currArea ] == carParkPos) || (LEFT_AREA[currArea ] == carParkPos) ) { isClose = true; trace("carPark is close"); } return isClose; } /** tryMove @param int - indicates the Area to try to move into @return int attempts to change current Area to value indicated by param return indicates result */ public int tryWalk(int into) { int result; if ((RIGHT_AREA[currArea ] == into) || (FORWARD_AREA[currArea ] == into) || (BACKWARD_AREA[currArea ] == into) || (LEFT_AREA[currArea ] == into)) { trace("move into Area " + into ); currArea = into; if (currArea == paparazziPos) { result = PHOTOGRAPHED; } else { if (currArea == carParkPos) { result = BORED; } else { result = MOVE_OK; } } } else { result = NOT_POSSIBLE; } trace("result of attempt to move: " + result); return result; } /** releaseTheDog @param int - indicates the area to release the little dog into @return int attempts to release a little dog into the area indicated by param return indicates result */ public int releaseTheDog(int into) { int result; if((RIGHT_AREA[currArea ] == into) || (FORWARD_AREA[currArea ] == into) || (BACKWARD_AREA[currArea ] == into) || (LEFT_AREA[currArea ] == into)) { trace("release little dog into Area " + into ); trace("paparazzi is at " + paparazziPos); if (into == paparazziPos) { result = PAPARAZZI_FOUND; } else { result = DOG_LOST; } } else { result = NOT_POSSIBLE; } trace("result of attempt to release little dog: " + result); return result; } /** getCurrent @return int returns number of current area */ public int getCurrent() { return currArea; } /** nextArea @param char - indicates direction required l - left hand area r - right hand area f - Area forward b - Area backward @return int returns number area in direction indicated by param (if param is not an acceptable value returns NOT_POSSIBLE) */ public int nextArea(char direction) { int nextIs; switch (direction) { case LEFT: nextIs = LEFT_AREA[currArea]; break; case FORWARD: nextIs = FORWARD_AREA[currArea]; break; case BACKWARD: nextIs = BACKWARD_AREA[currArea]; break; case RIGHT: nextIs = RIGHT_AREA[currArea]; break; default: nextIs = NOT_POSSIBLE; } trace("next area " + direction + " is " + nextIs); return nextIs; } /** getLittleDogsName @param int - indicates the dog whose identity is required a value between 1 and 3 inclusive @return String the name of the requested dog */ public String getLittleDogsName(int dogNumber) { return LITTLE_DOGS[dogNumber-1]; } /** setTracing @param boolean - indicates state of tracing messages true turns them on false turns them off */ public void setTracing(boolean on) { tracing = on; } /** trace @param String - the message use to display tracing messages shown if the variable tracing is true */ public void trace(String message) { if (tracing) { System.out.println("StarletsWorld: " + message); } }}PROGRAM I NEED2 CHANGE -/** PhotoShoot @author: Alexander Bender 068854 @version: purpose: KXT101 assignment 2, semester 1, 2007*/import java.util.Scanner;public class PhotoShoot { private StarletsWorld londonSheraton; private boolean tracing; private Scanner sc; public PhotoShoot() { sc=new Scanner(System.in); tracing = true; explain(); play(); } public void play() { boolean ProgramRun=true; char yesno; String tempyesno; trace("play method"); System.out.println("Would you like to play (y)es or (n)o? "); tempyesno = sc.next(); yesno = tempyesno.charAt(0); if ((yesno == 'y') || (yesno == 'Y')) { ProgramRun=true; } else { ProgramRun=false; } while ( ProgramRun == true) { trace("play game"); System.out.println("lol"); StarletsWorld sw; //starlets,setupz, paparazzi, carpark, walk, dog, current, next_A, dogname, tracing , tracezor; int number_areas, current_area, right_area, left_area , forward_area, backwards_area, number_of_dogs = 3 , pap_pos, next_walk, walk_result; String dogsnames[] , action; boolean paparazzi_adj=false , carpark_adj=false; char action_char; // //starlets = new StarletsWorld(); sw = new StarletsWorld(); sw.newGame(); current_area=sw.newGame(); //pap_pos=sw.paparazziPos(); //sw.setTracing; // sw.trace(sw.RIGHT_AREA[sw.currArea ] + "-" + sw.carParkPos); // trace(RIGHT_AREA[currArea ] + "-" + carParkPos); // trace(FORWARD_AREA[currArea ] + "-" + carParkPos); //trace(BACKWARD_AREA[currArea ] + "-" + carParkPos); // trace(LEFT_AREA[currArea ] + "-" + carParkPos); //right_area= StarletsWorld.RIGHT_AREA[current_area] //setupz = new StarletsWorld(); sw.setUp(1); number_areas = sw.getNumAreas(); //System.out.println(+number_areas); //current = new StarletsWorld(); sw.getCurrent(); current_area= sw.getCurrent(); //System.out.println(+current_area); //current_area= sw.currArea(); //System.out.println(+current_area); //paparazzi = new StarletsWorld(); sw.paparazziAdjacent(); paparazzi_adj = sw.paparazziAdjacent(); sw.carParkAdjacent(); carpark_adj = sw.carParkAdjacent(); //carpark = new StarletsWorld(); sw.carParkAdjacent(); //walk = new StarletsWorld(); //walk.tryWalk(); //dog = new StarletsWorld(); //next_A = new StarletsWorld(); //next_A.nextArea(); //dogname = new StarletsWorld(); //dogname.getLittleDogsName(); //dogsnames.getLittleDogsName; //number_of_dogs = dogname.LITTLE_DOGS(); //dogname.getLittleDogsName(); left_area= sw.nextArea(sw.LEFT); right_area= sw.nextArea(sw.RIGHT); forward_area= sw.nextArea(sw.FORWARD); backwards_area= sw.nextArea(sw.BACKWARD); System.out.println("you are in area #"+current_area); System.out.println("On your left is area #"+left_area); System.out.println("On your right is area #"+right_area); System.out.println("Forward is area #"+forward_area); System.out.println("Backward is area #"+backwards_area); System.out.println(" "); System.out.println("You currently have " +number_of_dogs+"remaining little dogs."); if (paparazzi_adj=true) { System.out.println("You hear the unmistakable sound of camera flashes re-charging..."); } if(carpark_adj=true) { System.out.println("Hmm, it seems a little dark in here..."); } System.out.println("What would you like to do, (w)alk, (r)elease a dog, or (q)uit? "); action = sc.next(); action_char = action.charAt(0); System.out.println("Action equals"+ action_char); switch(action_char) { case 'w': System.out.println("To which area number do you wish to walk?"); next_walk = sc.nextInt(); //System.out.println("walk to area " +next_walk); walk_result = sw.tryWalk(next_walk); System.out.println(walk_result); switch(walk_result) { case 11: current_area = next_walk; break; } break; case 'r': break; case 'q': System.out.println("GAME OVER"); ProgramRun=false; } // if (action == "w") //{ // System.out.println("To which area number do you wish to walk?"); // next_walk = sc.nextInt(); // } System.out.println("Would you like to play (y)es or (n)o? "); tempyesno = sc.next(); yesno = tempyesno.charAt(0); if ((yesno == 'y') || (yesno == 'Y')) { ProgramRun=true; } else { ProgramRun=false; } } trace("Thank you for playing. Now get to class."); } public void explain() { trace("explain the game"); System.out.println ("AVOID THE PAPARAZZI\n" + "================\n" + " \n" + "Imagine if you will:\n"+ "London Sheraton is a young Starlet, an actress, a singer, a model, an\n"+ "heiress, and one of undiscovered talent. She finds herself in a\n"+ "shopping mall, a system of interconnected shops. London loves to shop\n"+ "and will stroll with her little dogs (Tinks, Dinks, and Kinks) for\n"+ "hours looking for bargains. Unfortunately, there is a pack of\n"+ "She must avoid them as on this particular day she has a pimple on her\n"+ "face. Fortunately, the photographers are frightened of dogs and if a\n"+ "dog were to enter the shop they would run far away leaving London to\n"+ "shop by herself. Unfortunately, the shopping mall also contains a car\n"+ "finding herself in a car park without any shops. If she becomes bored\n"+ "she will leave the shopping complex altogether.\n"+ " \n"+ "The user is able to move London from her current store in one of four\n"+ "directions (forward, backward, left, and right). Each movement will\n"+ "result in London moving around the shopping mall to another shop or\n"+ "to the car park. If she is moved to the car park, she will become\n"+ "terminally bored and the game will end.\n"+ " \n"+ "Whenever London is in a shop, while browsing, she may release one of\n"+ "her little dogs in a nominated direction. If the little dog runs into\n"+ "a shop that contains the paparazzi, then they will flee leaving her\n"+ "to shop in peace and the game is over. If a little dog enters a shop\n"+ "that does not contain the paparazzi, it is overcome by loneliness and\n"+ "catches a limousine home.\n"+ " \n"+ "If London enters a shop containing the paparazzi then her pimply face\n"+ "is captured on film forever, her reputation is ruined, and the game\n"+ "is over.\n"+ " \n"+ "When London is in a shop adjacent to the car park, she can sense this\n"+ "because shops adjacent to the car park are dim due to the\n"+ "overwhelming shadows of hulking Sports Utility Vehicles.\n"+ " \n"+ "When London is in a shop adjacent to the shop containing the\n"+ "paparazzi she can hear the tell-tale sound of camera flashes\n"+ "re-charging.\n"+ " \n"+ "Good luck."); } public void trace(String message) { if(tracing) { System.out.println("PhotoShoot: " + message); } }}