Advertisement
Guest User

adventure text java

a guest
Oct 7th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.50 KB | None | 0 0
  1.      import java.util.Scanner;
  2.  
  3.     public static void main (String [] args) {
  4.  
  5.          /**
  6.           * Thing.
  7.           *
  8.           * This class defines things with the help of a list.
  9.           */
  10.      public class Thing {
  11.  
  12.      Scanner keyboard = new Scanner (System.in) ;
  13.  
  14.         String name;
  15.        Thing nextThing;
  16.  
  17.       Thing(String n){ name = n;
  18.  
  19.    }
  20.  
  21.         /**
  22.         * giving a name to the thing
  23.         *
  24.         * @param n Name
  25.          */
  26.       void setName(String n){
  27.       navn = n;
  28.     }
  29.  
  30.      /**
  31.        * Getting the name of the thing
  32.        *
  33.        * @return Name
  34.        */
  35.       String getName(){
  36.       return name;
  37.   }
  38.  
  39.      /**
  40.        * placing the next thing on the list
  41.        *  
  42.        * @param t Thing
  43.        */
  44.     void setNextThing(Ting t){
  45.     nextThing = t;
  46.       }
  47.  
  48.     /**
  49.      * Getting the next thing from the list
  50.      *  
  51.      * @return Thing
  52.      */
  53.       Thing getNextThing(){
  54.       return nextThing;
  55.     }
  56.  
  57.   }
  58.  
  59.  
  60.     import java.util.Scanner;
  61.  
  62.        /**
  63.         * Room.
  64.         *
  65.         * This class defines rooms with the help of a list.
  66.         */
  67.         public class Room {
  68.  
  69.        Room roomEast;
  70.        Room roomWest;
  71.        Room roomNorth;
  72.        Room roomSouth;
  73.  
  74.        Thing thing;
  75.  
  76.        /**
  77.         * placing a thing in the room.
  78.         *
  79.         * @param t Thing which is to be placed
  80.         */
  81.          void placeAThing(Thing t){
  82.           // TODO: Implement
  83.       }
  84.  
  85.         /**
  86.          * Writing out the content of the room, also the neighbour room
  87.          */
  88.         void lookInRoom(){
  89.         // TODO: writing out the things in the room.
  90.         // TODO: write out neighbour rooms
  91.    }
  92.  
  93.           /*
  94.            * Placing things in the room
  95.            *
  96.            * @param t Thing
  97.            */
  98.          void placeThing(Thing t){
  99.          thing = t;
  100.      }
  101.  
  102.      /*
  103.       * Getting things in the room
  104.       *
  105.       * @return Thing
  106.       */
  107.        Thing getThing(){
  108.         return thing;
  109.     }
  110.  
  111.        /*
  112.         * Placing the room to the east
  113.         * @param r Room
  114.         */
  115.         void setEast(Room r){
  116.         roomEast = r;
  117.   }
  118.  
  119.       /*
  120.        * Getting the room at east
  121.        *  
  122.        * @return Room
  123.        */
  124.        Room getEast(){
  125.        return roomEast;
  126.     }
  127.  
  128.       /*
  129.        *  Placing the room at west
  130.        *
  131.        * @param r Room
  132.        */
  133.        void setWest(Room r){
  134.        roomWest = r;
  135.     }
  136.  
  137.         /*
  138.         * getting the room at west
  139.         *
  140.         * @return Room
  141.         */
  142.        Room getWest(){
  143.        return roomWest;
  144.    }
  145.  
  146.      /*
  147.       * Placing the room at north
  148.       *
  149.       * @param r Room
  150.       */
  151.         void setNorth(Room r){
  152.         roomNorth = r;
  153.      }
  154.  
  155.         /*
  156.           * Getting the room at north
  157.           *
  158.           * @return Room
  159.           */
  160.           Room getNorth(){
  161.           return roomNorth;
  162.       }
  163.  
  164.        /*
  165.         * placing the room at south
  166.         *
  167.         * @param r Room
  168.         */
  169.        void setSouth(Room r){
  170.        roomSouth = r;
  171.    }
  172.  
  173.        /*
  174.         * Getting the room at south
  175.         *
  176.         * @return Room
  177.         */
  178.         Room getSouth(){
  179.         return roomSouth;
  180.          }
  181.  
  182.     }
  183.  
  184.  
  185.  
  186.  
  187.  
  188.     import java.util.Scanner;
  189.      import java.util.Random;
  190.  
  191.        /**
  192.         * House.
  193.         *
  194.         * Parts that shall expand is marked with "TODO:".
  195.         */
  196.          public class house {
  197.  
  198.        public static void main ( String [] args ){
  199.        Scanner input = new Scanner(System.in);
  200.        Random rand = new Random();
  201.  
  202.        System.out.println("Welcome!");
  203.  
  204.     // Create room and connect them
  205.     Room room = new Rom();
  206.     room.placeAThing(new Ting("footbal"));
  207.     room.placeAThing(new Ting("chair"));
  208.     room.placeAThing(new Ting("coffe"));
  209.      // TODO: Create moore rooms
  210.  
  211.  
  212.  
  213.     // main loop
  214.      boolean finished = false;
  215.      while(!finished){
  216.       room.lookInRoom();
  217.       // TODO: let the user move between rooms
  218.       System.out.println("Write place to place a new thing in the room, or quit:");
  219.      //System.out.println("Write place to place a thing in the room, east/west/south/north to move to a neighbour room, or quit:");
  220.        switch(input.nextLine()){
  221.       case "place":
  222.     // TODO Get name of the thing in the room
  223.       break;
  224.        case "quit":
  225.         finished = true;
  226.         break;
  227.        default:
  228.       System.out.println("Unknown command");
  229.           }
  230.    }
  231.  
  232. }
  233.  
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement