Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public abstract class Location
- {
- private String locName = " ";
- private String longDesc = " " ;
- private String shortDesc = " " ;
- //private ArrayList<Item> items = new ArrayList<Item>();
- private Item items;
- private boolean colombus = false;
- protected ArrayList<Location> nearbyLocations = new ArrayList<Location>();
- private ArrayList<String> roads = new ArrayList<String>();
- public Location (String locName, String longDesc, String shortDesc, Item items)
- {
- this.locName = locName;
- this.longDesc = longDesc;
- this.shortDesc = shortDesc;
- this.items = items;
- }
- // public boolean noFurtherRoad(Player player, String command)
- // {
- // if(player.getLocation().equals(player.setLocation(plains)))
- //// }
- public Item getItems() {
- return items;
- }
- public void setItems(Item items) {
- this.items = items;
- }
- public boolean isColombus()
- {
- return colombus;
- }
- public void setColombus(boolean colombus)
- {
- this.colombus = colombus;
- }
- public void OwerWriteLocation (Location loc)
- {
- this.locName = loc.locName;
- this.longDesc = loc.longDesc;
- this.shortDesc = loc.shortDesc;
- }
- public void setLocations (Location loc, String road)
- {
- this.nearbyLocations.add(loc);
- this.roads.add(road);
- }
- public void possibleActions()
- {
- itemCheck();
- for (String road : this.roads)
- {
- if (road != null)
- {
- System.out.println("There is a road leading " + road +'.');
- }
- }
- }
- public String getName()
- {
- return locName;
- }
- public void setName(String locName)
- {
- this.locName = locName;
- }
- public String getShortDescription()
- {
- return shortDesc;
- }
- public void setShortDescription(String description)
- {
- this.shortDesc = description;
- }
- public String getLongDescription()
- {
- return longDesc;
- }
- public void setLongDescription(String description)
- {
- this.longDesc = description;
- }
- public void describeYourSelf()
- {
- if(this.colombus == false)
- {
- System.out.println(this.longDesc);
- colombus = true;
- }
- else if(this.colombus == true)
- {
- System.out.println(this.shortDesc);
- }
- }
- public Location getNextLocation(String command)
- {
- switch (command)
- {
- case "north":
- return this.nearbyLocations.get(0);
- case "east":
- return this.nearbyLocations.get(1);
- case "south":
- return this.nearbyLocations.get(2);
- case "west":
- return this.nearbyLocations.get(3);
- }
- return null;
- }
- public void itemCheck()
- {
- if (items != null)
- {
- System.out.println("There is a "+ items.getName() + " on the ground" );
- }
- }
- public void doCommand(Player Player, String command)
- {
- switch (command)
- {
- case "north":
- case "east":
- case "south":
- case "west":
- Player.setLocation(this.getNextLocation(command));
- break;
- case "take shovel":
- case "take torch":
- case "take elven_robe":
- if(items != null)
- {
- Player.addToInventory(items);
- System.out.println("You have added "+ items.getName() + " to your inventory");
- Player.getLocation().items = null;
- }
- break;
- case "items":
- Player.printInventory();
- default :
- if(command.equals("help"))
- {
- System.out.println( "You can move around by typing north/south/west/east. \n");
- }
- // default "help":
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement