Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What do you need to do for this assessment? Task: In this assignment, you are going to design and implement classes and use them to
What do you need to do for this assessment?
Task:
In this assignment, you are going to design and implement classes and use them to write and modify programs. Marks will be awarded for a correct answer that shows good understanding of the C concepts: classes, data types, problem solving, and inheritance.
Specification
The aim of the coursework is to develop and implement a set of classes that represent the different elements that appear in a game. You are not developing the complete game, just the setting up specific snapshots and display of the game. The system will have a console application that will display the board and the entities using ASCII.
You are required to write a 'level' editor for a simple game called MysteryWorld. A level in MysteryWorld is a room made up from x grid. Each cell in the room is referred to by the row and column number coordinate Hence the @ in the room shown in Figure is placed at cell :
Game Specifications
A room in MysteryWorld can be populated by two types of entities: inanimate and animate entities.
There are two kinds of inanimate entities: stones which are represented by S and holes which are represented by a O Holes also have a depth in meters represented by a number between and Expectedly, inanimate do not move.
Each living entity has a measure of its health, represented using an integer value between and and all the living entities can move. There are three types of living entities: dragons represented by the symbol # human beings represented by @; and monsters represented by a character. Each human being has a name, the monsters have strength represented by a number between and
All the animate objects can move and their health is usually reduced when they move.
Animate entities wandering around the world
o Humans: The humans always move to the cell to on their right, provided that this cell is not occupied and that they are not at the edge of the room. Otherwise they move to unoccupied randomly chosen cell adjacent to their current position. Their health is reduced by one every time that they move.
o A dragon moves to a cell that is randomly chosen from those cells that are unoccupied, and adjacent to its current position. The health of the dragon is very volatile and is reduced by a random number between and every time it moves.
o Monsters: A monster moves as many cells as its strength at any direction up down, left or right as long as the destination is free and the monster remains within the room. For instance, the monster in position in Figure with strength can move to position but it cannot move to because the cell is occupied, the monster cannot move to any other cell because it will reach the end of the room. In the case that there are not possible movements, the monster will move to a random empty cell next to it The health is reduced as many points as the strength.
Note: In the unlikely event that all the possible options are invalid, the entity will not move. Furthermore, the default movement of all the living entities is to a random adjacent cell.
A typical level for a game would look like the following:
This shows stones, holes, humans, monsters and dragons on this level. Note that a full stop is used to denote an unoccupied cell in the level.
S #
O
@
O
S
@
# @
Figure
You will work only with the console application to test your implementation. It is suggested that you have the following classes at a minimum:
Entity class: This is an abstract class which will act as the parent base class to all the different entities Holes Stones, Humans... of the game.
Room class: This is the class that stores the positions of all the entities. It should ideally contain the Methods to add entities, display the room, display information etc.
Main class: This is the main class that handles the game. The menu will be implemented here and you will need to add the call to the specific actions.
Functional Requirements
The program should be a console application. The user interacts with the program by typing instructions into the standard input, and the program gives output by writing to the standard output.
When the program starts, it should display the initial state of the game, and a menu. The initial state of the game should contain holes, stones, monsters, humans, dragons, placed randomly in the room, with the constraint that two entities cannot occupy the same position. In the initial state, the depth of the holes is a random number between and monsters will be allocated a random strength between and and the three humans will be: Harold, David and Clar
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started