Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java For this assignment, students will develop a turn-based ghost hunting game with two different levels of ghosts. The key learning objectives for this

In java

For this assignment, students will develop a turn-based ghost hunting game with two different levels of ghosts. The key learning objectives for this assignment are: ability to setup and use classes, understanding and using inheritance, use of overloaded constructors.

The overall game concept: You are a ghost hunter character in a game. You are trying to clear the ghosts from a haunted house. As you enter each room, you encounter ghosts that you must battle in order to move on. Once you have battled and destroyed 3 ghosts and the boss ghost, the house is cleared and it is ready for a family to move in.

Since both ghost types share common attributes, you will setup a parent or super class for Ghost with the shared attributes. Then you will create subclasses that differentiate the specific characteristics of the regular or boss ghost.

Both ghost types will have attributes for their name and the "damage" they inflict on a character. The default constructor for the base or super class, will be to initialize the values to null and zero.

Class RegularGhost: A Regular ghost has a unique attribute for "health restored" to the character once the battle is over and it has been defeated. This value will add to the health of the ghost hunter. This ghost class will have overloaded constructors for three types of ghosts 1) default (no parameters) is 20% chance of escape, 15 damage, and 10 health restore 2) Parameter for chance of escape and damage 3) Parameter for chance of escape, user defined damage levels, and health restore. The parameters will be set in the constructors based on asking the user if they want the game setting on easy, medium, or hard.

Class BossGhost: A Boss ghost has a unique attributes for "health" and "damage taken". There is one overloaded constructor for this class: health and damage inflicted are parameters based on the user difficulty setting. The amount of damage taken will be determined by the battle method chosen by the user. This will impact the health, so at a minimum, you will need setters and getters for the health attribute.

Class GhostHunt: Main program

Pseudocode for Gameplay:

1) Introduce the game to the user

2) Ask the user for a setting level (easy, medium, hard)

3) Ask the user for their character name

4) Introduce the setting

5) Ask the user the room they want to enter, each room has a different ghost (objects with unique names created from default and overloaded constructors)

6) Describe the room

7) The character encounters a regular ghost: Describe the ghost, tell user the battle has started

- Random result based on chance of escape for ghost sucked up or escapes, or damage inflicted to character

- Check for ghost dead or character dead

- Ask user if they want to continue battle or run away

- Repeat above steps until either the user runs away, or the ghost or character loses

- If the user chooses to run away then continue

- If the user wins, then add the "health restored" and continue

- If character/user loses: end game

8) Repeat 5 and 6 until 3 ghosts have been defeated or the character/user loses

9) The character enters the final room and encounters a boss ghost

- Ask the user which tool they want to use (such as: magic spell, ectoplasm vacuum)

- Random result whether it works or not and whether ghost inflicts damage on them or not

- Check for boss ghost or character out of health

- Then repeat the first step of the boss battle until one of them is out of health

- If character/user loses: end game

- If character wins then Congratulate the user on winning! and end your story (the family moves in, everybody is happy, etc.)

For any of your assignments, if the details are not provided, it is up to the designer to choose how they want to implement the requirements. Typically in the workplace, people are not provided with a problem so specific that every aspect is scripted for them. Similarly, I like to provide students the opportunity to make some of their own decisions as the code designer, within the bounds of the guidance and intent of the program. For example, students can come up with any room descriptions that they want. The minimum number of rooms is 4, since the user needs to complete 3 ghosts before moving on to the boss. However, you could have additional descriptions for room choices and additional ghost object instances for more rooms, but only one for each ghost is required. The health starting point and different parameters for the constructor based on level are also up to the designer. If you choose the character health too high, the player will always win, if you choose it too low, they will always lose. Once you play your own game, you can adjust these for a decent player experience. sure to turn in all the java class files and execution screenshots that show the user interface functions.

Hint: One approach for coding the chance of escape is to use a method for a random number generator to generate a number between 0 and 99 (100 to represent 100%). You can then check to see if the answer is in a certain range and use that to reflect the % chance of escape. For example, If I generate a random number between 0 and 99 and then check to see if the number is between 0 to 15, the probability it is in that range is 15%. Therefore, if the ghost escapes only if the number is in that range, then it will escape randomly 15% of the time.

Example of turn-based battle code:

https://codestudent.net/2019/10/23/java-text-rpg-5-battle-system/

Sample output mock-up:

Welcome to the Ghost Hunting Game. The objective is to use your ghost hunting equipment to clear all the ghosts from the house. What is your name?

Jenny

Nice to meet you Jenny! Enter the number for your level of experience as a ghost hunter: beginner ghost hunter (1), somewhat experienced (2) or expert (3)?

1

As you enter the house, I can see that you have full health at a level of 100.

I see that you also have an ectoplasm vacuum to suck up ghosts to make the house safe.

You are now in the front hall and can enter one of these rooms.

Which room would you like to enter? Enter the number for your choice.

Choices: dining room (1), living room (2) , kitchen (3), basement (4)

3

You have entered the kitchen. The kitchen is in disarray, with food scattered about and the dishes broken on the floor. You encounter a MadChef ghost that is wielding a turkey leg as a weapon.

Do you want to battle (enter 1) or run away (enter 0)?

1

Oh no, the ghost got away and attacked you!! Your health is now 85. Do you want to battle (enter 1) or run away (enter 0)?

1

You have defeated the ghost!! Your health has been restored and is now 95.

Which room would you like to enter? Enter the number for your choice.

Choices: dining room (1), living room (2) , kitchen (3), basement (4)

1

You have entered the dining room. It is setup for a formal meal lit only by flickering candles. You see a ghost with the face of a skeleton dressed in a tuxedo sitting at the head of the table.

Do you want to battle (enter 1) or run away (enter 0)?

You have defeated the ghost!! Your health has been restored and is now 95.

Which room would you like to enter? Enter the number for your choice.

Choices: dining room (1), living room (2) , kitchen (3), basement (4)

2

You have entered the living room. The furniture is covered with sheets and the room is dusty. A sheet shifts and a ghost emerges.

Do you want to battle (enter 1) or run away (enter 0)?

0

Which room would you like to enter? enter the number for your choice.

Choices: dining room (1), living room (2) , kitchen (3), basement (4)

3

This room has already been cleared and has no ghosts.

Which room would you like to enter? Enter the number for your choice.

Choices: dining room (1), living room (2) , kitchen (3), basement (4)

2

You have entered the living room. The furniture is covered with sheets and the room is dusty. A sheet shifts and a ghost emerges.

Do you want to battle (enter 1) or run away (enter 0)?

1

Oh no, the ghost got away and attacked you!! Your health is now 80.

Do you want to battle (enter 1) or run away (enter 0)?

1

You have defeated the ghost!! Your health has been restored and is now 90.

Which room would you like to enter? enter the number for your choice.

4

You have entered the basement. It is the creepiest room of all. It is dark and full of bugs and old tools. A ghost emerges from under the stairs.

Do you want to battle (enter 1) or run away (enter 0)?

1

Your ectoplasm vacuum is only partially effective on this ghost. You could also use a magic spell.

What do you want to use? Enter 1 for the vacuum or 2 for a spell.

1

You inflicted 40 damage so it's health is now 60. The ghost counter attacked with slime and you sustained 20 damage, so your health is now 80.

What do you want to use? Enter 1 for the vacuum or 2 for a spell.

2

You used a freezing spell. You inflicted 50 damage so it's health is now 10. The ghost counter attacked with slime and you sustained 20 damage, so your health is now 60.

1

What do you want to use? Enter 1 for the vacuum or 2 for a spell.

1

The vacuum worked!! Congratulations!!! You have defeated the ghost!!! The house is cleared and the family can now move in!! They are very grateful!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions