JAVA please:
Glad you just gained new OOP knowledge, you want to implement it
and create your first game.
You want your game to be a two-player fight. Each
player has 100% life at the
beginning.
During the game, one player may hit the other
player. When a player is hit, he loses 1% of his
life.
Because you want your game to be as customizable as possible,
you want to let each player choose their name in the game.
Before you get started, think about implementing the basic game
class:
Requirements:
In this issue you will need to write a Game class that contains the
following methods:
●receivesHit (int) - receives as a parameter
the id of the hit player (1 for the first player and 2 for the
second, respectively).
●displayStatus () - displays the status of
the game on the screen in the following format: player_name_1:
player_life_1 - player_name_2: player_life_2.
The class can be instantiated in 2
ways:
●through a constructor that receives 2 String parameters that
represent the name of the first player, respectively the name of
the second player.
●through a parameterless constructor, in which case the name of the
first player will be Player1 and the name of the second will be
Player2.
Specification:
- It is guaranteed that a player will never lose his whole
life.
Example:
JAVA please: Glad you just gained new OOP knowledge, you want to implement it and create your first game. You want your
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
JAVA please: Glad you just gained new OOP knowledge, you want to implement it and create your first game. You want your
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!