Page 1 of 1

For this C# practice problem, you are tasked with creating a program for a monster battlegame called Digimonsters, in la

Posted: Mon May 09, 2022 6:17 am
by answerhappygod
For this C# practice problem, you are tasked with creating a
program for a monster battlegame called Digimonsters,
in language C#. Each Digimonster has
statistics, and can use those stats to battle other Digimonsters.
Your Digimonster can level up to become more powerful. After the
opposing Digimonster is defeated, you can battle again, or
heal.
Additional details: You are to design an Digimonster class.
Please be sure to include the following methods:
• A constructor to randomly assign stats for your Digimonster.
The constructor should take one argument, a string variable called
“name”.
• A Roll6 method to simulate the rolling of one six-sided die,
returning the result of the roll.
• A Roll20 method to simulate the rolling of one twenty-sided
die, returning the result of the roll.
• A ToString method that returns the Digimonster’s name and
stats formatted nicely
• A Battling method that takes two arguments, a char “command”
and an opponent Digimonster. The command can either be to attack or
run. If it is run, use Roll6. For 2-6, exit the battle without
taking damage. A result of 1 lets the opponent attack you and the
battle continues. The attack command does damage to the opponent
equal to your attack stat (you take damage equal to your opponent’s
attack stat). Battle returns true if you failed to run or if you
chose attack and both you and your opponent still have health
remaining. Battle returns false if either you successfully ran or
you or your opponent lose all health. If your opponent loses all
health, set battleWin to true.
• A Heal method sets your currentHP to the value of your maxHP.
It cannot be called if you are currently in battle.
• A LevelUp method calls the Roll6 method twice, adding the
first result to your attack and the second to your maxHP. It will
not work if you have not won a battle since you have last leveled
up. Set battleWin to false. The monster has a handful of
attributes: Attack, set by the constructor to the result of a Roll6
call; maxHP, set by the constructor to 10 + the result of a Roll20
call; currentHP, set to the same thing as maxHP by default;
inBattle, a boolean set to false by the constructor; battleWin, a
boolean set to false by the constructor. In the Main method:
• Instantiate two Digimonster objects, gathering each name
from the user.
• In a loop, ask the user if the monster should attack, run,
heal, level up, or quit. Validate your input.
• After each selection by the user, call the appropriate method
and then the ToString for both Digimonster.
• Selecting “quit” should exit the program.
Example execution:
Welcome to the world of Digimonster. What is your creature's
name again?
Jokomon↵
Okay! It's Jokomon. Your rival also has an Digimonster. What was
its name?
Hulumon↵
Ah! This will be a fight between your Jokomon and your rival's
Hulumon. Enter 'A' to attack, 'R' to run, 'H' to heal, 'L' to level
up, or 'Q' to quit.
X↵
That is not a valid option. Try again.
h↵
You have healed Jokomon.
Jokomon is level 1, has 5 attack and 13/13 health.
Hulumon is level 1, has 4 attack, and 14/14 health.
A↵
You exchange attacks! Jokomon is level 1, has 5 attack and 9/13
health.
Hulumon is level 1, has 4 attack, and 9/14 health.
a↵
You exchange attacks! Jokomon is level 1, has 5 attack and 5/13
health.
Hulumon is level 1, has 4 attack, and 4/14 health.
A↵
You exchange attacks! Hulumon was knocked out!
Jokomon is level 1, has 5 attack and 5/13 health.
Hulumon is level 1, has 4 attack, and -1/14 health.
L↵
You have leveled up! Jokomon is level 2, has 7 attack and 9/16
health.
Hulumon is level 1, has 4 attack, and 14/14 health.
H↵
You have healed Jokomon.
Jokomon is level 2, has 7 attack and 16/16 health.
Hulumon is level 1, has 4 attack, and 14/14 health.
l↵
You need to win another battle before leveling up again.
Jokomon is level 2, has 7 attack and 16/16 health.
Hulumon is level 1, has 4 attack, and 14/14 health.
Q↵
Thanks for playing!