Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave
Further Object-Oriented Programming Assessment: Design and Inheritance
Answered

Adding a Goal (10 marks)

Introduction

You work with the given project haunted Castle Start.This is yet another variant of the game of Zuul that is described in Chapter 8 of the module text book. This variant uses a different scenario, namely a haunted castle. You will extend the project towards a more interesting game. Note the difference in class structure. There is a split between the classes Game and GameMain. The latter is the textual user interface of the game, the former is the actual game independent of any particular user interface (we could use it for example with a graphical user interface where commands are selected from menus). Furthermore, commands are structured rather differently from the book, using lambdas.

All knowledge about the command language is in the Parser. There are several classes and methodsthat currently do not serve any purpose. They are there for you to extend as described below. Start by familiarising yourself with the source files of the project. The project contains assertions for some contracts and test classes. These are part of the specification of what you have to implement. Many of the tests fail in the given project. Through your work more and more of these tests should pass; if you do all tasks, then nearly all tests should pass (Adding dual ghosts can make a few tests fail that passed beforehand!). You should never remove or change these contracts or test classes. You can add to them, but this is not required.

The assessment will be marked out of 100 and provisional marks have been associated with the individual components. Most of the marks will be obtained by passing tests of a testsuite that will be added to the project after your submission. This test suite will include some of the tests that are already in the project, but there will be many more tests. Make sure that you do not only write code, but that you also write or update appropriate comments for all classes and methods. Furthermore, you have to keep to the program style guide of the book. After marking out of 100 as indicated below, between 0% and 20% may be subtracted if you violate the style guide. In extreme cases even more than 20% can be subtracted.

Note that there are dependencies between the tasks given below, but it is possible to do some of them in a different order. Note that you have to submitthe assessment before the deadline; there are no “grace days”.

Adding Time (10 marks)

The aim of the game shall be to reach the bedroom. After the player has entered the bedroom a congratulatory message shall be printed and the game ends. 2 All your changes will be in the classes Game and Player. You will need a new field in the class Player. Make changes in the goRoom method.

Playing the game shall have a time limit. Do not use real time but instead count the number of movements of the player. The initial time limit shall be 12. If the goal has not been reached within the time limit, then the player loses. Losing means that a corresponding message is printed and the game ends. Note that if in the last time step the player reaches the goal, then the player should win, not lose because time runs out. Make only changes in the classes Game and Player and keep them minimal.

Add the command lookto the commands that the game understands. The purpose of lookis to print out the description of the room and the exits again (we “look around the room”). This could be helpful if we have entered a sequence of commands in a room so that the description has scrolled out of view and we cannot remember where the exits of the current roomare. You will have to add to the class Game and modify the class Parser.

A ghost has a description. Complete the implementation of class Ghost. Its toString() method shall return the description.

We extend the game such that a room knows about the characters inside it. Extend the class Room with a field such that a room can contain zero or many characters. Add a method addCharacter that adds a character to a room and a method remove Character that removes a character from a room. Modify the constructor and the method movein class Character, so that they ensure that the presence or absence of a character is correctly recorded in a room. Extend the getLongDescriptionmethod to include a list of all the characters in the room. For this purpose use the toString()method of the character. Note that there will be at least one character in a room of the castle, namely the playerthemselves. Finally, add two different objects of class Ghostto some rooms in the scenario by changing class Game.

Every time the player performs a “go” command, every ghost shall move in the castle to a random room. Because ghosts can move through walls, a ghost can go in one step to any room; it does not have to follow exits. Implement the method Ghost.goRandom and ensure that it is called from Game. To help with moving all ghosts randomly, add two collections to class Game: one shall contain all rooms and the other one all ghosts.

A solid ghost islike a ghost, but it cannot go through walls. So when going to another random room it can only follow an exit to the next room. Complete the implementation of class SolidGhost. Add one solid ghost to the scenario in class Game.

The dual of a direction is the opposite direction. For example, the dual of north is south and the dual of up is down. The dual of a dual is again the original direction. A dual ghost changes a room in that it changes all exits to their duals. For example, usually the west exit of the great hall leads to the hall and the south exit of the great hall leads to the chapel. When a dual ghost isin the great hall,suddenly the two exits of the great hall are east and north; the east exit leads to the hall and the north exit leads to the chapel.

When a dual ghost leaves a room, all exits return to normal. When there are two dual ghosts in a room, the room has exits as normal; so two dual ghosts cancel out each other’s effect. Implement a dual method in enum Direction. Implement a dual method in class Room, that changes the room’s exits as described above. Complete the implementation of class DualGhost, so that its movement between rooms has the described effect on rooms’ exists. Add one dual ghost to the scenario in class Game.

support
close