Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class TextAdventure {
  5.  
  6.     public static void main(String[] args) {
  7.         // TODO Auto-generated method stub
  8.  
  9.         String i_command;
  10.         Location startingRoom = new Location("Starting Room", "A blank white room.");
  11.         Player protaginist = new Player(startingRoom);
  12.         WorldObject smallPottedCactus = new WorldObject("Small Potted Cactus", "A cactus that has been planted in a small pot. It has begun to flower.", 0.35);
  13.        
  14.         protaginist.currentInventory.addWorldObject(smallPottedCactus);
  15.        
  16.         System.out.println("Welcome to LOC");
  17.         System.out.println(protaginist.currentLocation.initialDescription);
  18.        
  19.         Scanner a = new Scanner(System.in);
  20.        
  21.         System.out.println("Try 'inventory' or 'inv' to look at your items.");
  22.         i_command = a.nextLine();
  23.        
  24.         if (i_command.equals("inventory") || i_command.equals("inv") )
  25.         {
  26.             for (WorldObject o : protaginist.currentInventory.inventoryObjects)
  27.             {
  28.                 System.out.println(o.name);
  29.             }
  30.            
  31.             i_command = a.nextLine();
  32.            
  33.             for (WorldObject o : protaginist.currentInventory.inventoryObjects)
  34.             {
  35.                 if (i_command.equals("examine " + o.name))
  36.                 {
  37.                     System.out.println(o.description);
  38.                 }
  39.             }  
  40.         }
  41.         else
  42.         {
  43.             System.out.println("No Command");
  44.         }
  45.        
  46.     }  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement