Class Map

java.lang.Object
  extended by Map

public class Map
extends java.lang.Object


Constructor Summary
Map()
           
 
Method Summary
static void printGrid(Universe g)
          This method prints the universe grid, labelling each location with a number.
static void printLocations(Universe g, Vehicle user)
          This method prints all the locations in the current Universe, indicating the player's current location as well.
static void printMap(Vehicle user)
          This method prints the position of each location in the universe, and the position of the player in the Universe (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Map

public Map()
Method Detail

printMap

public static void printMap(Vehicle user)
This method prints the position of each location in the universe, and the position of the player in the Universe (i.e. the location the player is at). This method obtains the Universe object (via Game.getUniverse()), and then calls printGrid() and printLocations() methods.

Parameters:
user - the Vehicle representing the user

printGrid

public static void printGrid(Universe g)
This method prints the universe grid, labelling each location with a number. This method will first print out a line stating something along the lines of, "Printing Universe." Then prints out the grid map of the Universe. Thus, it needs to go through each row, and print out a character for each column in a given row. As was the case for printLocations(), above, the size of the Universe will not be known ahead of time, and can be obtained via the getNumRows() and getNumCols() methods in the Universe object that is passed in to this method. For each spot in the 2-D array grid, either a dash ('-') is printed if there is no Location object there (i.e. getLocation() in the Universe class returns null), or a number is printed if there is a Location object there. As with printLocations(), the numbering must start at 1, and follow the numbering scheme described above. It is easiest to use tabs ("\t") to line up the numbers and dashes.

Parameters:
g - The Universe to print the grid of

printLocations

public static void printLocations(Universe g,
                                  Vehicle user)
This method prints all the locations in the current Universe, indicating the player's current location as well. This method will first print out a line stating something along the lines of, "The valid destinations are:" Then it will print out the list of the Locations in the order specified above. This method prints out the last 6 lines of the output shown above. This will most likely require nested for loops. Note that the size of the Universe will not be known ahead of time, and can be obtained via the getNumRows() and getNumCols() methods in the Universe object that is passed in to this method. The order and numbering for the locations is very specific, and is described above. When the location of the player's Vehicle is printed, the method should print out "(your location)" next to that location name. Note that this method does NOT print the actual grid -- that's done by the printGrid() method, below.

Parameters:
g - The Universe to print the grid of
user - The player's Vehicle, used to get the player's current location