100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Game.java Carleton University SYSC 2004 CA$14.41   Add to cart

Exam (elaborations)

Game.java Carleton University SYSC 2004

 5 views  0 purchase
  • Course
  • Institution

import .Stack; /** * This class is the main class of the "World of Zuul" application. * "World of Zuul" is a very simple, text based adventure game. Users * can walk around some scenery. That's all. It should really be extended * to make it more interesting! * * To play this game, crea...

[Show more]

Preview 2 out of 6  pages

  • February 19, 2023
  • 6
  • 2022/2023
  • Exam (elaborations)
  • Questions & answers
avatar-seller
import java.util.Stack;
/**
* This class is the main class of the "World of Zuul" application.
* "World of Zuul" is a very simple, text based adventure game. Users
* can walk around some scenery. That's all. It should really be extended
* to make it more interesting!
*
* To play this game, create an instance of this class and call the "play"
* method.
*
* This main class creates and initialises all the others: it creates all
* rooms, creates the parser and starts the game. It also evaluates and
* executes the commands that the parser returns.
*
* @author Sama Adil Shekh
* @version October 21, 2017
*/

public class Game
{
private Parser parser;
private Room currentRoom;
private Room backRoom;
private Stack<Room> sBack;
/**
* Create the game and initialise its internal map.
*/
public Game()
{
createRooms();
parser = new Parser();

backRoom = null;
//intializes a stack of rooms
sBack = new Stack<Room>();

}

/**
* Create all the rooms and link their exits together.
*/
private void createRooms()
{
Room outside, theatre, pub, lab, office;
//some items to be in the rooms
Item bench, waterfountain, desk, stool, chair, computer, book;

//create the items
bench = new Item("Bench", 35);
waterfountain= new Item ("Water fountain", 43);
desk = new Item("Desk", 25);
stool = new Item("Stool", 7);
chair = new Item("Chair", 13);
computer = new Item("Computer", 20);
book = new Item("Book", 3);

// 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");

This study source was downloaded by 100000850872992 from CourseHero.com on 02-18-2023 22:53:49 GMT -06:00


https://www.coursehero.com/file/27690749/Gamejava/

, //items in each room
outside.addItem(bench);
outside.addItem(waterfountain);
theatre.addItem(chair);
theatre.addItem(book);
theatre.addItem(desk);
pub.addItem(stool);
lab.addItem(desk);
lab.addItem(chair);
lab.addItem(computer);
lab.addItem(book);
office.addItem(desk);
office.addItem(computer);
office.addItem(chair);



// 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);

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 the World of Zuul!");
System.out.println("World of Zuul is a new, incredibly boring adventure
game.");
System.out.println("Type 'help' if you need help.");
System.out.println();

This study source was downloaded by 100000850872992 from CourseHero.com on 02-18-2023 22:53:49 GMT -06:00


https://www.coursehero.com/file/27690749/Gamejava/

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller ExamsConnoisseur. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for CA$14.41. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79202 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
CA$14.41
  • (0)
  Add to cart