Map - public class Map cfw Call this method with two int's...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Map { p /** * Call this method with two int's to get the appropriate room * The valid range for both x and y is 0 to 3 * * @param x * @param y * @return Room */ public Room getRoom(int x, int y) { return myMap[x][y]; } /** * Hi! I'm a 2 dimensional array! Though I look kinda weird, * I'm here to help make your programs better. But don't worry, * you don't have to use me for this project. If you're curious how * I work, see chapter 7 in your textbook. */ private Room [][] myMap; p /** * Hey wassup dawg? I'ma constructor. I make the objects round these parts, * sometimes without even trying, knowwhatimssayin? * Yall don't haveta worry 'bout me for this'ere game, but look me up in * Chapter 6 sometime. Kay? * */ public Map() { myMap = new Room[4][4]; m Key theKey = new Key(); Chest theChest = new Chest(); theChest.lock(theKey); t for (int i = 0; i < myMap.length; i ++) { for (int j = 0; j < myMap[i].length; j ++) { myMap[i][j] = createRoom(i,j, theChest, theKey); m } } } /** * PAY NO ATTENTION TO THE METHOD BEHIND THE CURTAIN!!!! * _________________________________________________ * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | |
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
* | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | * ------------------------------------------------- * * * Seriously don't look below until you've completed the project, * it'll spoil the surprise! * * @param x * @param y * @param theChest * @param theKey * @return Room */ private Room createRoom(int x, int y, Chest theChest, Key theKey) { p switch (x) { case 0: switch (y) { case 0: return new Room("FOREST TRAIL:\nYou are standing on a dirt trail that leads to the east. Surrounding you is the famously thick underbrush\n" + "of Oconee Forest Park, the fall leaves falling off the trees have just started to poke holes in the canopy.\n" + "Off in the distance you hear the cool sounds of Lake Herrick drifting through the trees.",false,false,true,false,false,null,null,null); case 1: return new Room("WOODEN WALKWAY:\nThe wooden walkway makes a :clump: as you stride along it.\n" + "Frogs give a terrified SKRIP! and jump to safety as your adventurous frame comes into view.\n" + "A mountain biker, ignoring the many \"Fragile Habitat\" signs, speeds along a narrow dirt path to your right.\n" + "As you reach the end of the walkway, you notice a hole in the ground in a newly fallen tree's footprint, just\n" +
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

Map - public class Map cfw Call this method with two int's...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online