Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Tesk 1 Create a Player class, that represents a player. Put this in playercpy. Every Player has a name ( String ) , and a
Tesk
Create a Player class, that represents a player. Put this in playercpy.
Every Player has a name String and a health level integer and a manna level integer The health affects if you stay alive in the game, and the manna level affects how much you can wield a weapon to attack other players.
Create a constructor for Player that takes a String for the name, and initializes the health to and manna to
Create gelters for the name getname and health gethealth and manna getmanna
Task
Createa Potion class that represents a potion. Drinking a potion restores a Player's health. Put this in potion.pyEvery Potion has a name, and a benefit level int representing how many points it restores to a Player if the potion is drunk.
Create a constructor for Potion that takes a String name, and and a benefit level, and initializes the name and benefit level for that potion. If the benefit level is not specified, the default value is read about default arguments here
Create a getter getname that returns the name of the potion.
Create a getter getbenef it that returns the benefit level of the potion.
Create a drink method that
Returns the value of the benefit level of the potion, and
Reduces the benefit value of the potion to after you drink a potion, it loses all potency
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