The 'world-of-zuul' game - how can I implement testing please?

Hello,
I am just running through a tutorial using the 'world-of-zuul' game to get me up to speed with Java, and I am at the stage where by I need to implement automatic testing for my back command. I have created my TestGame class but I am not sure where to take my tutorial from here?
I thought of creating a new instance of my class Game in TestGame and using the goRoom() command enter a room, then use my back() command, then print out the results to see if I am in the original room.
Has anyone any experience with this small program who can help me? Thank you in advance for any advice :-)
class Game
    private Parser parser;
    private Room currentRoom,previousRoom;
    private Item roomItem;
    public static void main(String[] args) { //cannot change method (static) - String to accept arguments
        Game g; //reference variable, points to instance of game class
        g = new Game(); //new instance of the Game class
        g.play(); //using our new instance of Game call the play method to play the game       
     * Create the game and initialise its internal map.
    public Game()
        createRooms();
        parser = new Parser();
     * Create all the rooms and link their exits together.
    private void createRooms()
        Room outside, theatre, pub, lab, office;
        // create the rooms
        outside = new Room("outside the main entrance of the university");
        theatre = new Room("in a lecture theatre");
        pub = new Room("in the campus pub");
        lab = new Room("in a computing lab");
        office = new Room("in the computing admin office");
        // initialise room exits
        outside.setExit("east", theatre);
        outside.setExit("south", lab);
        outside.setExit("west", pub);
        theatre.setExit("west", outside);
        pub.setExit("east", outside);
        lab.setExit("north", outside);
        lab.setExit("east", office);
        office.setExit("west", lab);       
        // initialise room items
        outside.setItem("pole", 80);
        pub.setItem("wand", 10);
        pub.setItem("pencil", 5);
        currentRoom = outside; // start game outside
     *  Main play routine.  Loops until end of play.
    public void play()
        printWelcome();
        // Enter the main command loop.  Here we repeatedly read commands and
        // execute them until the game is over.
        boolean finished = false;
        while (! finished) {
            Command command = parser.getCommand();
            finished = processCommand(command);
        System.out.println("Thank you for playing.  Good bye.");
     * Print out the opening message for the player.
    private void printWelcome()
        System.out.println();
        System.out.println("Welcome to Adventure!");
        System.out.println("Adventure is a new, incredibly boring adventure game.");
        System.out.println("Type 'help' if you need help.");
        System.out.println();
        System.out.println(currentRoom.getLongDescription());
     * Given a command, process (that is: execute) the command.
     * If this command ends the game, true is returned, otherwise false is
     * returned.
    private boolean processCommand(Command command)
        boolean wantToQuit = false;
        if(command.isUnknown()) {
            System.out.println("I don't know what you mean...");
            return false;
        String commandWord = command.getCommandWord();
        if (commandWord.equals("help"))
            printHelp();
        else if (commandWord.equals("go"))
            goRoom(command);
        else if (commandWord.equals("back"))
            back(command);
        else if (commandWord.equals("quit")) {
            wantToQuit = quit(command);
        return wantToQuit;
    // implementations of user commands:
     * Print out some help information.
     * Here we print some stupid, cryptic message and a list of the
     * command words.
    private void printHelp()
        System.out.println("You are lost. You are alone. You wander");
        System.out.println("around at the university.");
        System.out.println();
        System.out.println("Your command words are:");
        parser.showCommands();
     * Try to go to one direction. If there is an exit, enter the new
     * room, otherwise print an error message.
    private void goRoom(Command command)
        if(!command.hasSecondWord()) {
            // if there is no second word, we don't know where to go...
            System.out.println("Go where?");
            return;
        String direction = command.getSecondWord();
        // Try to leave current room.
        Room nextRoom = currentRoom.getExit(direction);
        if (nextRoom == null)
            System.out.println("There is no door!");
        else {
            previousRoom = currentRoom; //store previous room (in order to enable back command)
            currentRoom = nextRoom;
            System.out.println(currentRoom.getLongDescription());
     * "Back" was entered. Takes the player into the last room he/she
     * has been in.
    private void back(Command command)
        if(previousRoom == null) {
            System.out.println("Sorry, cannot go back...");
            return;
        if(command.hasSecondWord()) {
            // if there is a second word, we cannot go back...
            System.out.println("I don't know what you mean...");
            return;
        currentRoom = previousRoom; //change location to the previous room
        //print method where you are
        System.out.println(currentRoom.getLongDescription());
     * "Quit" was entered. Check the rest of the command to see
     * whether we really quit the game. Return true, if this command
     * quits the game, false otherwise.
    private boolean quit(Command command)
        if(command.hasSecondWord()) {
            System.out.println("Quit what?");
            return false;
        else
            return true;  // signal that we want to quit
}

Anyone any ideas to help please?

Similar Messages

  • Hello! I was on my Mac and then I clicked on iTunes. Then I clicked on iTunes, and accidentally removed my device from my Mac, how can I get it back? Also when I plug my iPod into the computer, it downloads everything, how can I stop this. please help!thx

    Hello! I was on my Mac and then I clicked on iTunes. Then I clicked on Account, and accidentally removed my device from my Mac, how can I get it back? Also when I plug my iPod into the computer, it downloads everything that is on my computer, how can I stop this. please help! please help!!!!!!thank you

    Is the iPod still singed into the account isn Settings>iTunes and App Stores and SettingsZ>iCloudl? If it is then I would not be concerned.
    Also see:
    iTunes Store: Associating a device or computer to your Apple ID
    since you may have started the 90 day window.
    For the other "problem", go to iTunes>Preferences>Devices and check the box that says Prevent iPod....automatically syncing.

  • I have 2 games Words with Friends and Cityville that receives a Pop-up message form iTunes...  "Connect to iTunes to use Push Notifications" and will not allow me to exit out of the app or play.  How can I get this message to STOP?

    I have 2 games Words with Friends and Cityville that receives a Pop-up message form iTunes...  "Connect to iTunes to use Push Notifications" and will not allow me to exit out of the app or play.  How can I get this message to STOP?

    Yes - I connected my phone to my computer / Itunes and went into the apps section, but from there I have no idea how to manage the push notifications.  I even tryied going into itunes that is installed on my phone.  I still cannot find anyplace to manage these popups.  I have also gone into settings - notifiations - and tried turning all notifications for these apps all off but that didnt work either.  Any guidance is MUCH appreciated - Im not sure where to go from here.

  • TS1702 The app game that I bought for iphone is not available in the itunes store anymore. How can I get it back on my iphone 4

    The app game that I bought for iphone is not available in the itunes store anymore. How can I get it back on my iphone 4

    If it's no longer in the store then you won't be able to re-download it - do you have a copy of it on your computer's iTunes (or on a backup) that you could sync back to your phone ?

  • Why are there so many more choices on the USA iTunes Store? Surely having an iTunes account should let you access all itunes availability the world over? Also how do you request films/tv series to the UK itunes?

    Why are there so many more choices on the USA iTunes Store? Surely having an iTunes account should let you access all itunes availability the world over?
    Also how do you request films/tv series to the UK itunes? There's tv series I'd like but they're incomplete like The Batman & Xena Warrior Princess. And films theta aren't available for download but you can purchase in a store like HMV?  Apple isn't doing itself any favours by secluding countries by their store. They'd make billions if you could just select the iTunes Store you want to search & purchase from just by signing in! If anything what they're doing is putting themselves into a corner, other companies like Samsung & HTC are already on too of them for innovation & ease of use. The people they're attracting are predominantly existing Apple users not new customers. What do you guys think?

    It's not Apple's choice, they can only sell a particular item where the content provider/rights-holder has granted them a license to sell them. Content is licensed by the rights-holders to Apple on a country-by-country basis, each country therefore has to have its own store, and you have to be in a country to use its store - they want control over where their content is available.
    You can try requesting that an item be added to the UK store via this page, but unless the rights-holder agrees to then Apple won't be able to sell it here : http://www.apple.com/feedback/itunes.html

  • I have recently purchased a hybred 750GbHDD as an upgrade for my MAC Book Pro (Intell Version) I have a boot camp partition to the original 500GB HDD. How can I expand both partitions to fit the new drive?

    I have recently purchased a hybred 750GbHDD as an upgrade for my MAC Book Pro (Intell Version) I have a boot camp partition to the original 500GB HDD. How can I expand both partitions to fit the new drive?
    I have tried bootcamp and have had no luck due to the fact that boot camp doesn't see the additional HDD space of 250Gb. What am I not doing?

    Ouch, well there is a problem.
    This is the stack of partitions on your old drive
    EFI (hidden)
    Lion (50GB say)
    Bootcamp (50GB say)
    Lion Recovery Partiton (hidden)
    This is the same stack on your new drive imaged from the old one.
    EFI (hidden)
    Lion (50GB say)
    Bootcamp (50GB say)
    Lion Recovery Partiton (hidden)
    Emtpy Space (100GB say)
    This is what you want
    EFI (hidden)
    Lion (100GB say)
    Bootcamp (100GB say)
    Lion Recovery Partiton (hidden)
    EFI has to be at the top of the drive and Lion Recovery has to be at the bottom of the drive.
    And you only have four partitions.
    You can't move the Lion Recovery Partition or Bootcamp partiton, however you can expand the Lion Partition into empty space below it. (but can't delete or move the Lion Recovery partition)
    Your Duplicator duplicated perfectly, too perfectly Likely would work with same sized drives/partitions.
    This is what your going to need to do.
    You need to move the Bootcamp partition to a blank external drive using WinClone and disconnect. This is so you have two backups of it. (one on your old 500GB drive)
    You will need a drive enclousre or IDE/SATA to USB adapter cable for the older 500GB drive and option key boot from it. (some enclosures can't be booted from so check first Other World Computing is good place to ask)
    Download the free Carbon Copy Cloner, grab any new files off the new 750GB internal drive to the old 500GB your booted from.
    Open Apple's Disk Utility and Erase with Zero option the entire internal 750GB drive and let it rip, this will map off as many bad sectors and improve reliability.
    Now use Carbon Copy Cloner to clone the 500GB Lion + Lion Recovery Partitions to the internal 750GB, it will "fix" things and place Lion Recovery at the bottom of the drive where it belongs, give all the extra space to OS X Lion.
    Next your going to have to follow WinClones instructions to restore your Bootcamp, likely you will have to recreate the Bootcamp partition first (in Bootcamp) to the size you want and then clone. Likely Winclone may "fix" Windows to recognize it's in a new larger partition now. I don't know you'll have to check as I haven't used it.
    When Bootcamp creates the partition it will place it near the bottom next to the Lion Recovery Partition.
    As you know you will have to re-validate Windows with Lord Redmond or it expires as you changed the hardware.

  • Omputcer has been installed with a German programme, originally programmed in English with English keyboard. The keys are the same as before but the keyboard is now programmed in German and I cannot find the way to enter @. How can I do it?

    My computer has been installed with a German programme, originally programmed in English with English keyboard. The keys are the same as before but the keyboard is now programmed in German and I cannot find the way to enter @. How can I do it?

    Hello r555,
    Thank you for being a My Best Buy member, and thank you for visiting our forum.  I am very sorry to hear that it has not always been easy for you to receive your Gamers Club Unlocked bonus when trading in games.  I'll be happy to talk to you about your experience.
    I get the impression you are quite familiar with the trade-in process and how the bonus is applied, and it is disappointing to hear that a store associate wouldn't attempt to complete that process.  I will be sending you a private message so we can get some more specific information regarding which store you were at as well as the trade in question where you did not receive the bonus.  Please watch for a message from me shortly.
    Sincerely,
    Mike|Social Media Specialist | Best Buy® Corporate
     Private Message

  • I downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    i downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    hi philly, thanks for getting back to me, especially on such a busy day.
    I don't think that's quite the issue though. I bought an album and it appears in 'my purchases' within the itunes app. Yet, in order to listen to the music, i must use the 'music' app and in this application, there are only three tracks displayed at any one time from my downloaded album.
    I can 'download all' from the 'my purchases' section but that still doesn't help, it just keeps the last three tracks downloaded in the music app.
    I have the 'icloud' enabled and wondered if it had anything to do with that.
    i have successfully downloaded another full album totally into the music app, but this first album is causing me problems.

  • I have recently updated my CC programs to the latest version and now all of my files wont open by default into their respective programs, only if I open the program and go to file open and open the file from there. How can I fix this?

    I have recently updated my CC programs to the latest version (CC2014) and now all of my files wont open by default into their respective programs, only if I open the program and go to file>open and open the file from there. How can I fix this?
    I have tried 'Open with' and the version of the program now installed on my computer isn't even suggested as an option and when I browse for it, the file wont open with it anyway

    On Windows (don't know about Mac), the latest version will always take over the file association, and become the default for indd files. It's impossible to change it.
    But there is a plugin for ID that makes this possible. Never tried it myself.
    https://www.rorohiko.com/wordpress/downloads/lightning-brain-soxy/

  • When I create a New Folder (on the desktop or in Finder), the system uses the Generic Document Icon instead of the Generic Folder Icon. How can I change this back?

    When I create a New Folder (on the desktop or in Finder), the system uses the Generic Document Icon instead of the Generic Folder Icon. How can I change this back?
    All of a sudden I noticed that most of the folders on my computer were no longer using the folder icon, but the generic document icon. I had to manually change back the icon being used by opening Get Info for each folder and copying and pasting the generic folder icon from some folders that remained unchanged. Now whenever I create a New Folder (right click -> "New Folder"), the icon that shows up is the generic document icon (white page with top right corner turned down). And I have to manually change it so it shows up as a folder in Finder or on my desktop. I don't know why or how this switch happened. All of the folders now on my computer look ok, but I need to change the default so when I create a New Folder it uses the correct icon.
    I have also Forced Relaunch of my Finder and rebooted the system. I downloaded Candybar but am not sure what will fix anything, so I haven't proceeded.
    Anyone know how I can do this? Thanks.

    Anyone?

  • HT1848 when i purchase ringtones and they download directly to the music app on iphone, how can I move them to SOUNDS in SETTINGS so I can assign to various functions please?

    when i purchase ringtones and they download directly to the music app on iphone, how can I move them to SOUNDS in SETTINGS so I can assign to various functions please?

    You would have to create the ringtones.
    Google will find several way to do this.
    You cannot buy ready made ringtones from your computer.

  • How can I change the default apple ID for app store. I bought the macbook from my school when I left and I'm the ID in place of mine is the computer departments one. How can i change it to mine?? Thanks

    How can I change the default apple ID for app store. I bought the macbook from my school when I left and I'm the ID in place of mine is the computer departments one. How can i change it to mine?? Thanks

    http://support.apple.com/kb/ht5621

  • I entered my gift card under the wrong email account. How can I change it?

    I entered my gift card under the wrong email account. How can I change it? It is really hard getting support from iTunes. It keeps throwing me back to Apple.

    This forum is for questions from those managing sites on iTunes U, Apple's service for colleges and universities to post educational material in the iTunes Store. You'll be most likely to get help with this issue if you ask in the general iTunes forums.
    Regards.

  • HT1871 Hello i have one IPhone 4S and I use 3G net in my mobile sometime I have problem with temperature in my phone at the SIM card or battery how can I fix this problem. By update or version of 6.1.3

    Hello i have one IPhone 4S and I use 3G net in my mobile sometime I have problem with temperature in my phone at the SIM card or battery how can I fix this problem. By update or version of 6.1.3

    Could it be because the SIM card got damaged while I cut it to fit the IPhone?
    Very likely. Hard to believe the carrier in Mexico doesn't have a micro-SIM card available.
    Or somehow the Chinese carrier found out and locked it?
    No, which is not possible.
    What can I do? Get a new SIM and see if it works again?
    Get a micro-SIM from the carrier in Mexico that you don't have to manually cut down. If that carrier doesn't provide one, switch to another carrier that is not so low-budget.

  • HT1918 i have recently moved from the uk to australia and cancelled my uk debit before the payment was processed for songs i bought in itunes. i have tried to edit my billing info with australian debit details but the site says 'invalid card' how can i fi

    i have recently moved from the uk to australia and cancelled my uk debit before the payment was processed for songs i bought in itunes. i have tried to edit my billing info with australian debit details but the site says 'invalid card' how can i fix this?

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

Maybe you are looking for