Project 5 - Maze game engine

Project 5 Maze - Robert J England II COS 221 Projects 5& 6 Maze Program Project done for Prof Larry Latour Monday The following is the actual

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Robert J. England II COS 221 Projects 5 & 6 Maze Program Project done for Prof. Larry Latour Monday, December 08, 2006 The following is the actual code used in the program. This time, the test is done with a special debug command during standard program running. // Maze.cpp : // Maze game engine created by Robert J. England // containing Room, RoomLink, RoomList, and Player classes // for COS 221 with Larry Latour // at the University of Maine in Orono // Friday, December 08, 2006 // #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std; class Room; // declaration before use in RoomLink class class RoomLink { public : // Constructor RoomLink(Room * v) : value(v), nextLink(0), prevLink(0) {}; // POST: Creates a room link for use in a list, with a // room value v // Data fields Room * value; RoomLink * nextLink; RoomLink * prevLink; }; class RoomList { public : // Constructor RoomList() : firstLink(0), lastLink(0) {}; // POST: Creates an empty list of rooms // Accessor methods Room * back() { if (lastLink) return lastLink->value; else return 0;}; // POST: Returns the last room in the list, if it exists; // otherwise null is returned Room * front() { if (firstLink) return firstLink->value; else return 0;}; // POST: Returns the first room in the list, if it exists; // otherwise null is returned Room * findRoom(string name); // POST: Finds a room in the list by its name; if the room // is not in this list, null is returned Room * nextRoom(Room * thisRoom); // POST: Finds this room in the list and returns the next // room, if it exists; null is returned if either this or // the next room does not exist void printRooms(); // POST: Prints a sequence of room names to the screen // Modifier methods void addRoom(Room * newRoom); // POST: newRoom is added to the room list, if it is not // already in the list void readBuilding(); // PRE: The room list must be the building list // (i.e. the list of all rooms used in the game) // POST: The entire list of rooms is read from MazeCfg.txt // and the building is created from the input private : // Data fields RoomLink * firstLink; RoomLink * lastLink; }; class Room { public : // Constructor Room(string str) : name(str), doors( new RoomList) {}; // POST: A new room is created, with str as its name, and // zero rooms connected to it // Data fields string name; RoomList * doors; }; class Player { public : // Constructor Player() { building = new RoomList; myRoom = new Room( "Room1" ); loadGame( "Room1" );}; // POST: A new player is created, and a game is loaded // Modifier methods void loadGame(string roomname);...
View Full Document

This note was uploaded on 04/19/2008 for the course COS 221 taught by Professor Latour during the Fall '06 term at University of Maine Orono .

Page1 / 12

Project 5 Maze - Robert J England II COS 221 Projects 5& 6 Maze Program Project done for Prof Larry Latour Monday The following is the actual

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online