Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Room.java Carleton University SYSC 2004

Rating
-
Sold
-
Pages
2
Grade
A+
Uploaded on
19-02-2023
Written in
2022/2023

import .Set; import .HashMap; import .Iterator; import .ArrayList; /** * Class Room - a room in an adventure game. * * This class is part of the "World of Zuul" application. * "World of Zuul" is a very simple, text based adventure game. * * A "Room" represents one location in the scenery of the game. It is * connected to other rooms via exits. For each existing exit, the room * stores a reference to the neighboring room. * * @author Sama Adil Shekh * @version October 21, 2017 */ public class Room { private String description; private HashMapString, Room exits; // stores exits of this room. private ArrayListItem items; /** * Create a room described "description". Initially, it has * no exits. "description" is something like "a kitchen" or * "an open court yard". Intializes an ArrayList of items * in the room. * * @param description The room's description. */ public Room(String description) { iption = description; exits = new HashMapString, Room(); items= new ArrayListItem(); } /** * Define an exit from this room. * * @param direction The direction of the exit * @param neighbour The room to which the exit leads */ public void setExit(String direction, Room neighbour) { (direction, neighbour); } /** * Returns a short description of the room, i.e. the one that * was defined in the constructor * * @return The short description of the room */ public String getShortDescription() { return description; } /** * Return a long description of the room in the form: * You are in the kitchen. * Exits: north we

Show more Read less
Institution
Course

Content preview

import java.util.Set;
import java.util.HashMap;
import java.util.Iterator;
import java.util.ArrayList;
/**
* Class Room - a room in an adventure game.
*
* This class is part of the "World of Zuul" application.
* "World of Zuul" is a very simple, text based adventure game.
*
* A "Room" represents one location in the scenery of the game. It is
* connected to other rooms via exits. For each existing exit, the room
* stores a reference to the neighboring room.
*
* @author Sama Adil Shekh
* @version October 21, 2017
*/

public class Room
{
private String description;
private HashMap<String, Room> exits; // stores exits of this room.
private ArrayList<Item> items;
/**
* Create a room described "description". Initially, it has
* no exits. "description" is something like "a kitchen" or
* "an open court yard". Intializes an ArrayList of items
* in the room.
*
* @param description The room's description.
*/
public Room(String description)
{
this.description = description;
exits = new HashMap<String, Room>();
items= new ArrayList<Item>();
}

/**
* Define an exit from this room.
*
* @param direction The direction of the exit
* @param neighbour The room to which the exit leads
*/
public void setExit(String direction, Room neighbour)
{
exits.put(direction, neighbour);
}

/**
* Returns a short description of the room, i.e. the one that
* was defined in the constructor
*
* @return The short description of the room
*/
public String getShortDescription()
{
return description;
}

/**
* Return a long description of the room in the form:
* You are in the kitchen.
* Exits: north west

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


https://www.coursehero.com/file/27690734/Roomjava/

Written for

Course

Document information

Uploaded on
February 19, 2023
Number of pages
2
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$6.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExamsConnoisseur Self
Follow You need to be logged in order to follow users or courses
Sold
587
Member since
3 year
Number of followers
344
Documents
1492
Last sold
1 week ago

4.2

68 reviews

5
40
4
11
3
13
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions