Chat with us, powered by LiveChat java programming | Writedemy

java programming

java programming

  1. Open the zuul-bad project in BlueJ and save it as LastName-zuul1, using your last name, e.g., Smith-zuul1.
  2. Start by completing Exercises 6e: 8.1, 8.2, and 8.3  There is nothing to turn in for these exercises. As you design your game scenario, keep in mind the following:
    • Your game should have at least 6 rooms and no more than 10 rooms.
    • Each room should have a descriptive name.
    • Your rooms should be different from the rooms in the program already. Do not simply extend the existing scenario; create your own.
    • Be creative. This game scenario will be the basis for future assignments so make it something that will keep your interest.
  3. Complete Exercise 6e: 8.4 
    • Create a map of your game scenario in any common electronic format (such as .pdf, .doc, .pptx, .jpg, etc.).
    • Update the source code of your zuul project to create the rooms and connections as you designed them.
    • Update the welcome and help messages to match your scenario.
    • The rooms created in your zuul project and the connections from one room to another should match your map.
      • Make sure the connections between rooms are clear in your map. I will assume that connections between rooms are bidirectional unless you indicate otherwise (e.g., with arrowheads).
  4. Test your program.
  5. Document your changes.
    • Adjust the comment block at the top of the file to include a 1-2 sentence description of your specific game scenario.
    • Add your name to the @author list and update the version.
  6. When you have completed the assignment, create a jar file of your project:
    1. From BlueJ, choose Project->Create Jar File…
    2. Check the “Include source” checkbox  ← Very important!
    3. Name the file LastName-zuul1

Part 3: Git

In this part, you will install Git, a version control system, and use it to track source code for a simple project. Version control systems have two big advantages: (1) tracking versions of source code, and (2) facilitating collaboration among multiple developers working on the same code. In this lab, you will learn to use Git to track versions of source code.

Note: This part is a repeat of an assignment from CIS 133J. If you already have Git installed you don’t need to do that step, but you should complete all the other steps anew. Practicing the Git flow again will help you learn it. Do not resubmit a project from 133J. Each time you commit, a timestamp is associated with the commit.

  1. Walk through all the documents in the module Version Control with Git, learning about version control and following along with the steps. You may want to keep the Git Cheat Sheet for CIS 133J handy.
    1. Git and Version Control – informational.
    2. Install and Set Up Git – steps you need to follow to install Git on your local system.
    3. Set Up a Repository for a Project – steps you need to follow to create a local repository for a Java project.
    4. Add Features to a Project – steps you need to follow to add features to your Java project while tracking the changes in the repository.
  2. In the process of walking through the documents above you should have created a Hello World project and repository, which is what you will submit for this part of the lab.
  3. For full credit, your project repository must meet the criteria below. (If you followed along with the videos, you should have everything you need.)
    • The Java code must compile and run without error, printing a hello message to the terminal.
    • The repository must have a feature branch on which the work was done, which has been merged into the master. (Check with ‘git branch’ – your feature branch should be listed.)
    • There must be at least 2 commits with feature work, beyond initializing the project. (Check with ‘git log’)
    • Your commits must have descriptive messages.
    • Your commits must have timestamps from this quarter.
    • Your name and email address must be set up in your Git installation. (Look at the Author line in ‘git log’)
    • The repository must be clean with no uncommitted changes. (When you do ‘git status’ it should say “On branch master, nothing to commit, working tree clean”)
  4. Your submission for this part should be a zip file containing your project folder (e.g., hello-world). Creating a jar file from the BlueJ project is not sufficient because the jar does not include the repository files. Git uses a hidden folder named .git to store its internal files, and this folder needs to be in the zip file along with your project files.
  5. game 
  6. /**
  7.  *  This class is the main class of the “World of Zuul” application. 
  8.  *  “World of Zuul” is a very simple, text based adventure game.  Users 
  9.  *  can walk around some scenery. That’s all. It should really be extended 
  10.  *  to make it more interesting!
  11.  * 
  12.  *  To play this game, create an instance of this class and call the “play”
  13.  *  method.
  14.  * 
  15.  *  This main class creates and initialises all the others: it creates all
  16.  *  rooms, creates the parser and starts the game.  It also evaluates and
  17.  *  executes the commands that the parser returns.
  18.  * 
  19.  * @author  Michael Kölling and David J. Barnes
  20.  * @version 2016.02.29
  21.  */
  22. public class Game 
  23. {
  24.     private Parser parser;
  25.     private Room currentRoom;
  26.         
  27.     /**
  28.      * Create the game and initialise its internal map.
  29.      */
  30.     public Game() 
  31.     {
  32.         createRooms();
  33.         parser = new Parser();
  34.     }
  35.     /**
  36.      * Create all the rooms and link their exits together.
  37.      */
  38.     private void createRooms()
  39.     {
  40.         Room outside, theater, pub, lab, office;
  41.       
  42.         // create the rooms
  43.         outside = new Room(“outside the main entrance of the university”);
  44.         theater = new Room(“in a lecture theater”);
  45.         pub = new Room(“in the campus pub”);
  46.         lab = new Room(“in a computing lab”);
  47.         office = new Room(“in the computing admin office”);
  48.         
  49.         // initialise room exits
  50.         outside.setExits(null, theater, lab, pub);
  51.         theater.setExits(null, null, null, outside);
  52.         pub.setExits(null, outside, null, null);
  53.         lab.setExits(outside, office, null, null);
  54.         office.setExits(null, null, null, lab);
  55.         currentRoom = outside;  // start game outside
  56.     }
  57.     /**
  58.      *  Main play routine.  Loops until end of play.
  59.      */
  60.     public void play() 
  61.     {            
  62.         printWelcome();
  63.         // Enter the main command loop.  Here we repeatedly read commands and
  64.         // execute them until the game is over.
  65.                 
  66.         boolean finished = false;
  67.         while (! finished) {
  68.             Command command = parser.getCommand();
  69.             finished = processCommand(command);
  70.         }
  71.         System.out.println(“Thank you for playing.  Good bye.”);
  72.     }
  73.     /**
  74.      * Print out the opening message for the player.
  75.      */
  76.     private void printWelcome()
  77.     {
  78.         System.out.println();
  79.         System.out.println(“Welcome to the World of Zuul!”);
  80.         System.out.println(“World of Zuul is a new, incredibly boring adventure game.”);
  81.         System.out.println(“Type ‘help’ if you need help.”);
  82.         System.out.println();
  83.         System.out.println(“You are ” + currentRoom.getDescription());
  84.         System.out.print(“Exits: “);
  85.         if(currentRoom.northExit != null) {
  86.             System.out.print(“north “);
  87.         }
  88.         if(currentRoom.eastExit != null) {
  89.             System.out.print(“east “);
  90.         }
  91.         if(currentRoom.southExit != null) {
  92.             System.out.print(“south “);
  93.         }
  94.         if(currentRoom.westExit != null) {
  95.             System.out.print(“west “);
  96.         }
  97.         System.out.println();
  98.     }
  99.     /**
  100.      * Given a command, process (that is: execute) the command.
  101.      * @param command The command to be processed.
  102.      * @return true If the command ends the game, false otherwise.
  103.      */
  104.     private boolean processCommand(Command command) 
  105.     {
  106.         boolean wantToQuit = false;
  107.         if(command.isUnknown()) {
  108.             System.out.println(“I don’t know what you mean…”);
  109.             return false;
  110.         }
  111.         String commandWord = command.getCommandWord();
  112.         if (commandWord.equals(“help”)) {
  113.             printHelp();
  114.         }
  115.         else if (commandWord.equals(“go”)) {
  116.             goRoom(command);
  117.         }
  118.         else if (commandWord.equals(“quit”)) {
  119.             wantToQuit = quit(command);
  120.         }
  121.         return wantToQuit;
  122.     }
  123.     // implementations of user commands:
  124.     /**
  125.      * Print out some help information.
  126.      * Here we print some stupid, cryptic message and a list of the 
  127.      * command words.
  128.      */
  129.     private void printHelp() 
  130.     {
  131.         System.out.println(“You are lost. You are alone. You wander”);
  132.         System.out.println(“around at the university.”);
  133.         System.out.println();
  134.         System.out.println(“Your command words are:”);
  135.         System.out.println(”   go quit help”);
  136.     }
  137.     /** 
  138.      * Try to go in one direction. If there is an exit, enter
  139.      * the new room, otherwise print an error message.
  140.      */
  141.     private void goRoom(Command command) 
  142.     {
  143.         if(!command.hasSecondWord()) {
  144.             // if there is no second word, we don’t know where to go…
  145.             System.out.println(“Go where?”);
  146.             return;
  147.         }
  148.         String direction = command.getSecondWord();
  149.         // Try to leave current room.
  150.         Room nextRoom = null;
  151.         if(direction.equals(“north”)) {
  152.             nextRoom = currentRoom.northExit;
  153.         }
  154.         if(direction.equals(“east”)) {
  155.             nextRoom = currentRoom.eastExit;
  156.         }
  157.         if(direction.equals(“south”)) {
  158.             nextRoom = currentRoom.southExit;
  159.         }
  160.         if(direction.equals(“west”)) {
  161.             nextRoom = currentRoom.westExit;
  162.         }
  163.         if (nextRoom == null) {
  164.             System.out.println(“There is no door!”);
  165.         }
  166.         else {
  167.             currentRoom = nextRoom;
  168.             System.out.println(“You are ” + currentRoom.getDescription());
  169.             System.out.print(“Exits: “);
  170.             if(currentRoom.northExit != null) {
  171.                 System.out.print(“north “);
  172.             }
  173.             if(currentRoom.eastExit != null) {
  174.                 System.out.print(“east “);
  175.             }
  176.             if(currentRoom.southExit != null) {
  177.                 System.out.print(“south “);
  178.             }
  179.             if(currentRoom.westExit != null) {
  180.                 System.out.print(“west “);
  181.             }
  182.             System.out.println();
  183.         }
  184.     }
  185.     /** 
  186.      * “Quit” was entered. Check the rest of the command to see
  187.      * whether we really quit the game.
  188.      * @return true, if this command quits the game, false otherwise.
  189.      */
  190.     private boolean quit(Command command) 
  191.     {
  192.         if(command.hasSecondWord()) {
  193.             System.out.println(“Quit what?”);
  194.             return false;
  195.         }
  196.         else {
  197.             return true;  // signal that we want to quit
  198.         }
  199.     }
  200. }
  201. ” command

*/

public class Command

{

    private String commandWord;

    private String secondWord;

    /**

     * Create a command object. First and second word must be supplied, but

     * either one (or both) can be null.

     * @param firstWord The first word of the command. Null if the command

     *                  was not recognised.

     * @param secondWord The second word of the command.

     */

    public Command(String firstWord, String secondWord)

    {

        commandWord = firstWord;

        this.secondWord = secondWord;

    }

    /**

     * Return the command word (the first word) of this command. If the

     * command was not understood, the result is null.

     * @return The command word.

     */

    public String getCommandWord()

    {

        return commandWord;

    }

    /**

     * @return The second word of this command. Returns null if there was no

     * second word.

     */

    public String getSecondWord()

    {

        return secondWord;

    }

    /**

     * @return true if this command was not understood.

     */

    public boolean isUnknown()

    {

        return (commandWord == null);

    }

    /**

     * @return true if the command has a second word.

     */

    public boolean hasSecondWord()

    {

        return (secondWord != null);

    }

}

room “

 */

public class Room 

{

    public String description;

    public Room northExit;

    public Room southExit;

    public Room eastExit;

    public Room westExit;

    /**

     * Create a room described “description”. Initially, it has

     * no exits. “description” is something like “a kitchen” or

     * “an open court yard”.

     * @param description The room’s description.

     */

    public Room(String description) 

    {

        this.description = description;

    }

    /**

     * Define the exits of this room.  Every direction either leads

     * to another room or is null (no exit there).

     * @param north The north exit.

     * @param east The east east.

     * @param south The south exit.

     * @param west The west exit.

     */

    public void setExits(Room north, Room east, Room south, Room west) 

    {

        if(north != null) {

            northExit = north;

        }

        if(east != null) {

            eastExit = east;

        }

        if(south != null) {

            southExit = south;

        }

        if(west != null) {

            westExit = west;

        }

    }

    /**

     * @return The description of the room.

     */

    public String getDescription()

    {

        return description;

    }

}

“Parser

*/

public class Parser 

{

    private CommandWords commands;  // holds all valid command words

    private Scanner reader;         // source of command input

    /**

     * Create a parser to read from the terminal window.

     */

    public Parser() 

    {

        commands = new CommandWords();

        reader = new Scanner(System.in);

    }

    /**

     * @return The next command from the user.

     */

    public Command getCommand() 

    {

        String inputLine;   // will hold the full input line

        String word1 = null;

        String word2 = null;

        System.out.print(“> “);     // print prompt

        inputLine = reader.nextLine();

        // Find up to two words on the line.

        Scanner tokenizer = new Scanner(inputLine);

        if(tokenizer.hasNext()) {

            word1 = tokenizer.next();      // get first word

            if(tokenizer.hasNext()) {

                word2 = tokenizer.next();      // get second word

                // note: we just ignore the rest of the input line.

            }

        }

        // Now check whether this word is known. If so, create a command

        // with it. If not, create a “null” command (for unknown command).

        if(commands.isCommand(word1)) {

            return new Command(word1, word2);

        }

        else {

            return new Command(null, word2); 

        }

    }

}

 “command Words “

 */

public class CommandWords

{

    // a constant array that holds all valid command words

    private static final String[] validCommands = {

        “go”, “quit”, “help”

    };

    /**

     * Constructor – initialise the command words.

     */

    public CommandWords()

    {

        // nothing to do at the moment…

    }

    /**

     * Check whether a given String is a valid command word. 

     * @return true if a given string is a valid command,

     * false if it isn’t.

     */

    public boolean isCommand(String aString)

    {

        for(int i = 0; i < validCommands.length; i++) {

            if(validCommands[i].equals(aString))

                return true;

        }

        // if we get here, the string was not found in the commands

        return false;

    }

}

  1.  

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order