CIS 260 Dungeon
The objective of this assignment is to create some classes that
use linked lists to get a basic dungeon explorer up and running. You will
also have to deal with multiple source files.
Requirements and Resources
You have to implement four classes for this program: Path, Room, Item, and Dungeon.
- PlayDungeon2.java: main program that runs game
- LinkedList.java: A generic linked list class you are required to use
- dungeon.txt: A generic linked list class you are required to use
Path
- Class name: Path
- Instance variables:
- access: public; type: String; name: direction
- access: public; type: String; name: to
- Constructors
- parameters: none; action: sets both instance variables to zero-length Strings
- parameters: direction, to; action: set instance variables using parameter values
- Method
- Override of toString(); returns: "Path: direction to destination" (where direction and destination are replaced by the instance variable values)
Item
- Class name: Item
- Instance variables:
- access: public; type: String; name: name
- access: public; type: String; name: description
- access: public; type: String; name: location
- Constructors
- parameters: none; action: sets name and description to zero-length Strings and location to null
- parameters: name, description, location; action: set instance variables using parameter values
- Method
- Override of toString(), returns: description
Room
- Class name: Room
- Instance variables:
- access: public; type: boolean; name: visited; initialize: false
- access: public; type: String; name: id
- access: public; type: String; name: name
- access: public; type: String; name: description
- access: public; type: LinkedList of Path objects; name: paths; initialize: new empty LinkedList
- access: public; type: LinkedList of Item objects; name: items; initialize: new empty LinkedList
- Constructors
- parameters: none; action: calls other constructor using zero-length Strings for all parameters
- parameters: id, name, description; action: set instance variables using parameter values
- Methods
- access: public; name: getPath; parameter: String direction;
purpose: iterates through paths linked list looking for Path with same direction as parameter
returns that Path object if found, otherwise returns null
- Override of toString(), returns: "Room: id: name" (where id and name are replaced with the instance variable values)
Dungeon
- Class name: Dungeon
- Instance variables:
- access: public; type: String; name: currentRoom; initialize to: zero-length String
- access: public; type: LinkedList of Room objects; name: rooms; initialize: new empty LinkedList
- Constructors: none (Java will write a default constructor for you)
- Methods
- access: public; name: getRoom; parameter: String id;
purpose: iterates through rooms linked list looking for a Room with the same id as parameter
returns that Room object if found, otherwise returns null
- Override of toString(), returns: "Room: id: name" (where id and name are replaced with the instance variable values)
Sample output
>java PlayDungeon2
You are in a large open computer lab
A large room with many computers that are available to the public.
Exits are: e, w
Enter command: help
Commands are: help, quit, look, drop, take, go, inv, and the exit directions
You are in a large open computer lab
Exits are: e, w
Enter command: look
You are in a large open computer lab
A large room with many computers that are available to the public.
Exits are: e, w
Enter command: think
Unknown command. Try again.
You are in a large open computer lab
Exits are: e, w
Enter command: go w
You are in the west hall
A long, carpeted hallway running north-south.
Exits are: w, nw, s, e
Enter command: s
You are in the west hall
A long, carpeted hallway running north-south.
Exits are: s, n
Enter command: quit
Thanks for playing. Visit again soon.