Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# Create a new class that contains methods Implement rules in the class properties Create new instances of the class and use the methods that

C#

Create a new class that contains methods

Implement rules in the class properties

Create new instances of the class and use the methods that you wrote

Directions

Create a new blank console application.

Add a class named Monster that has the following attributes: string name, int health, int

positionX, int positionY.

Create a constructor that initializes accepts data via parameters to create a new monster.

Create your properties for your fields and use them to access the fields. Use Alt + Insert and use

the dialog box to make this process go quickly!

Write the following methods that would be part of this class:

Write a method named alterHealth that takes in an integer value via parameter and increases or decreases health by that much. If the monsters health reaches 0, display to the console the monster is dead. The method does not need to return anything.

Set a maximum value for the monsters health and implement this rule in the Health property. If the monsters health reaches this value, display to the console the monster has reached its maximum health. No points for this step if you implement in the maximum value in a method; do this in the property!

Write a method named move that takes in two integer values via parameters. Use this information to change the x and y positions of the monster, relative to the current position (dont just assign the new value). This method does not need to return anything.

Assume the monster can gain health by resting. Write a method named rest that asks the user how many minutes the monster rested (do not collect via parameters); increase the health value by that number, calling the alterHealth method. This method does not return anything.

Override the ToString() to output the state of the monster. Make sure you display all fields.

Create at least three instances of monster in Main and invoke ALL of your methods on each one,

passing literals if data is required by any method.

Output the state of each monster after interacting with the instances to make sure your

methods are working properly.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions