/** *
 *  World.java
 *
 *  Revisions: 1.0 Sep. 02, 2002
 *               Created the World class
 *             1.1 Sep. 03, 2002
 *               Compiled, Tested, Run
 *             1.2 Sep. 05, 2002
 *               Commented (late thanks to failed winXP SP1)
 *			   1.3 Sep. 16, 2002
 *		         Added omit nulls, gg Outlook Express for not updating...
 *  
* * Collaboration Statement: * I worked on the homework assignment alone, using only * course materials. * * Created with JCreatorLE, some indents are off when viewed through notepad * or EMACS * * @author Jose Manuel Caban * @version Version 1.3, Sep. 16, 2002 */ public class World { private City[][] map; public static final boolean bDebug = false; //////////// //Modifier// //////////// public void setWorld(City[][] twoDArray){ map = twoDArray; } /////////// //Methods// /////////// /** *Find city at given latitude and longitude *@param lat, the latitude *@param lon, the longitude *@return the City, or NULL if none exists */ public City getCityAt(int lat, int lon){ City temp = new City(); if(map[lon][lat] != null){ temp = map[lon][lat]; return temp; } else { return null; } }//end of getCityAt(int lat, int lon) /** *Find cities at given latitude *@param lat, the latitude *@return the Cities at the given latitude */ public City[] getCititesAtLatitude(int lat){ //omit nulls without destroying map int nulls = 0; for(int i=0; i
* @param args a String array of command line arguments. */ public static void main(String[] args) { City[][] twoDArray = new City[16][6]; //create the 8 cities, 2 per row....mwahahaha... //city #1 twoDArray[0][0] = new City(); twoDArray[0][0].setName("Weston"); twoDArray[0][0].setCountry("United States"); twoDArray[0][0].setPopulation(4332); if(bDebug){ System.out.println("works"); System.out.flush(); } //city #2 twoDArray[0][3] = new City(); twoDArray[0][3].setName("Nerd Land"); twoDArray[0][3].setCountry("Everquest on WINEX"); twoDArray[0][3].setPopulation(4511); //too many, thats the population //city #3 twoDArray[1][2] = new City(); twoDArray[1][2].setName("Atlanta"); twoDArray[1][2].setCountry("Georgia"); twoDArray[1][2].setPopulation(3304000); //as of 2000, yes I checked //city #4 twoDArray[1][3] = new City(); twoDArray[1][3].setName("Vulcan"); twoDArray[1][3].setCountry("Nerdtopia"); //actually, I like Star Trek :| twoDArray[1][3].setPopulation(5252); //as of 2001 //city #5 twoDArray[2][0] = new City(); twoDArray[2][0].setName("Leene Square"); twoDArray[2][0].setCountry("Chrono Trigger Land"); twoDArray[2][0].setPopulation(21); //probably about right ;) //city #6 twoDArray[2][2] = new City(); twoDArray[2][2].setName("Doom"); twoDArray[2][2].setCountry("When Id was good"); twoDArray[2][2].setPopulation(3); //number of classics Id made //city #7 twoDArray[3][1] = new City(); twoDArray[3][1].setName("John Romero"); twoDArray[3][1].setCountry("Ion Storm"); //hehe, not anymore :( twoDArray[3][1].setPopulation(1); //city #8 twoDArray[3][3] = new City(); twoDArray[3][3].setName("Zelda"); twoDArray[3][3].setCountry("Miyamato's Best"); twoDArray[3][3].setPopulation(4); //number of classics he made /*************************************************************/ World world = new World(); world.setWorld(twoDArray); System.out.println(world.getCityAt(0,0)); System.out.println(world.getCityAt(2,1)); ////////// System.out.println("\n END TEST GETCITY START LAT\n"); ////////// //test latitude City[] latitude; latitude = world.getCititesAtLatitude(3); for(int i = 0; i