#K14931. Enemy Class Initialization
Enemy Class Initialization
Enemy Class Initialization
You are required to implement a simple Enemy
class that models an enemy in a game. The class has four attributes:
- name (string): the enemy's name. Default value:
"Enemy"
. - health (float): the enemy's health points. Default value:
50.0
. - damage (float): the enemy's damage points. Default value:
10.0
. - experience (integer): the enemy's experience points. Default value:
0
.
The constructor should allow any subset of these attributes to be specified. If an attribute is not provided, its default value is used. The final task is to create an instance of the enemy with the given parameters and output its attributes in the order: name, health, damage, experience separated by a single space.
Note: If an attribute is not provided in the input, use its default value. All numerical parameters are given in a format appropriate to their types. In particular, health and damage are floats and experience is an integer.
In your solution, you must read from standard input (stdin) and output to standard output (stdout).
The mathematical representation of the default values is given below in LaTeX format:
$$ name = \text{\"Enemy\"}, \quad health = 50.0, \quad damage = 10.0, \quad experience = 0 $$
inputFormat
The input begins with an integer T
representing the number of test cases. Each test case consists of:
- An integer
N
which indicates how many parameters are provided (whereN
can be 0, 1, 2, 3, or 4). N
lines each containing a parameter name and its value separated by a space. The valid parameter names are:name
,health
,damage
, andexperience
.
If a parameter is missing in a test case, use its default value: name = "Enemy"
, health = 50.0
, damage = 10.0
, experience = 0
.
Input is read from standard input (stdin).
outputFormat
For each test case, print a single line containing the enemy's attributes in the following order: name, health, damage, experience
. Separate each attribute with a single space. Output is written to standard output (stdout).
1
0
Enemy 50.0 10.0 0
</p>