Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TextAdventure {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String i_command;
- Location startingRoom = new Location("Starting Room", "A blank white room.");
- Player protaginist = new Player(startingRoom);
- WorldObject smallPottedCactus = new WorldObject("Small Potted Cactus", "A cactus that has been planted in a small pot. It has begun to flower.", 0.35);
- protaginist.currentInventory.addWorldObject(smallPottedCactus);
- System.out.println("Welcome to LOC");
- System.out.println(protaginist.currentLocation.initialDescription);
- Scanner a = new Scanner(System.in);
- System.out.println("Try 'inventory' or 'inv' to look at your items.");
- i_command = a.nextLine();
- if (i_command.equals("inventory") || i_command.equals("inv") )
- {
- for (WorldObject o : protaginist.currentInventory.inventoryObjects)
- {
- System.out.println(o.name);
- }
- i_command = a.nextLine();
- for (WorldObject o : protaginist.currentInventory.inventoryObjects)
- {
- if (i_command.equals("examine " + o.name))
- {
- System.out.println(o.description);
- }
- }
- }
- else
- {
- System.out.println("No Command");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement