Lab 7 Problem Statement
Lab 7 Problem Statement
Problem Statement
You and your buddies are ready for some lighthearted fun after an intense period of academic commitments. You’ve
turned to a two-player virtual warfare game in search of entertainment. In this game, players take on the roles of distinct
characters equipped with special abilities and weapons. You find this gaming adventure to be both entertaining and
educational, as you started reminding the OOP concepts learnt as you battle in the game.
Class Methods
• public int numberOfUses: Integer variable containing the number of uses of Special Ability
• public float health: Float variable to store the health points of the character
• public int power: Integer variable to store the power of the character
• public SpecialAbility specialAbility: Object of the abstract class Special Ability
Class Methods
• public abstract float useSpecialAbility(): Abstract Method of Character Class
1
• public void increaseHealth(float healthPoints): Function to increase the health of the character
• public void decreaseHealth(float healthPoints): Function to decrease the health of the character
Class Pheonix
Class Constructor
• public Phoenix(Gun gun, int health, int maxNumberOfUses, int experience, int power): Parame-
terized constructor for Phoenix
Note: Initialise special ability as HotHands with damage as (power + 0.1*experience) and nu-
mOfUses as maxNumberOfUses
Class Methods
• public float useSpecialAbility(): Function that calculates the damage and or heal caused by Special Ability
and decrements the value of numberOfUses by 1
Class Sage
Class Constructor
• public Sage(Gun gun, float health, int maxNumberOfUses, int experience, int power): Parameter-
ized constructor for Sage
Note: Initialise special ability as HealingOrb with heal as (power + 0.3*experience) and numO-
fUses as maxNumberOfUses
Class Methods
• public float useSpecialAbility(): Function that calculates the damage and or heal caused by Special Ability
and decrements the value of numberOfUses by 1
Class Jett
Class Constructor
• public Jett(Gun gun, float health, int maxNumberOfUses, int experience, int power): Parameter-
ized constructor for Jett
Note: Initialize special ability as MoonLight with lifeDrain as (power + 0.2*experience) and
numberOfUses as maxNumberOfUses
Class Methods
• public float useSpecialAbility(): Function that calculates the damage and or heal caused by Special Ability
and decrements the value of numberOfUses by 1
2
• public float damage: Float variable to store the amount of healthPoints that will decrease of the opponent
upon the use of HotHands
Class Constructor
• public HotHands(float damage, int numberOfUses): Parameterized Constructor for HotHands Class
• public float heal: Float variable to store the amount of healthPoints that will increase of the user upon the
use of HealingOrb
Class Constructor
• public HealingOrb(float heal, int numberOfUses): Parameterized Constructor for HealingOrb Class
• public float lifeDrain: Float variable to store the amount of healthPoints that will increase of the user and
decrease of the opponent upon the use of Moonlight
Class Constructor
• public MoonLight(float lifeDrain, int numberOfUses): Parameterized constructor of MoonLight Class
• public int damage: Integer containing the value of damage caused by Phantom
• public int recoil: Integer variable containing the value of recoil of Phantom
Class Constructor
• public Phantom(int damage, float accuracy, int recoil): Parameterized constructor for Phantom Class
Class Methods
• public float useGun(): Function to calculate the damage caused by Gun
3
• public int damage: Integer containing the value of damage caused by Vandal
• public int recoil: Integer variable containing the value of recoil of Vandal
Class Constructor
• public Vandal(int damage, float accuracy, int recoil): Parameterized constructor for Vandal Class
Class Methods
• public float useGun(): Function to calculate the damage caused by Gun
damage caused = (damage - 0.2*recoil)*accuracy
Class Game
Class Fields
Class Constructor
• public Game(Character player1, Character player2): Parameterized constructor of the class Game
Class Methods
• private void calculateDamageAndHealth(Character attacker, Character defender): Function to
change the Health points of attacker/defender based on damage/heal value.
Description:
1. If the damage/heal caused by the Special Ability is more than the damage caused by Gun and number of
uses left for Special Ability is greater than zero then:
(a) If the attacker is an instance of Phoenix, then decrease the health of defender
(b) If the attacker is an instance of Sage, then increase the health of the attacker
(c) If the attacker is an instance of Jett, then increase the health of the attacker and decrease the health of
the defender
2. Otherwise, the attacker uses Gun and reduces the health of the defender
3. Hint: Use useGun() and useSpecialAbility()
• public String simulate(): Function to simulate the game between two characters.
Description:
1. The game will consist of 10 rounds where in every round following things happen:
(a) Player 1 uses Gun or Special Ability
(b) The health of Player 1 and/or Player 2 is affected based on the Gun/Special Ability used
(c) If the health of Player 2 is less than or equal to zero, Player 1 wins
(d) Player 2 uses Gun or Special Ability
(e) The health of Player 1 and/or Player 2 is affected based on the Gun/Special Ability used
(f) If the health of Player 1 is less than or equal to zero, Player 2 wins
2. After 10 rounds:
(a) The player who has the greater health wins the game
(b) In case both the players have the same health, the game ends in a draw
3. Hint: Use calculateDamageAndHealth() function
4
Test Cases
1. For this lab, sample test cases are not given as a .jar file. You need to test using your own test
cases through code. For reference, one of the sample test cases has been included in the src folder.
2. Make sure you don’t upload the sample test case files. You should only upload the required .java
files of the classes mentioned in the question.
General Instructions
1. Please use the Javadoc to further understand the structure of the question, the exact prototype of the functions,
and return values.
2. Ensure that the name of the file is the same as the class name with the appropriate extension.
3. Ensure that the name of the methods is the same as those given in Javadoc. Failure to follow this instruction
may cause a deduction in credit even if the implementation is correct.
4. Please do not copy the names of methods from Javadoc directly; instead, write them out yourselves.
5. You are required to upload all the classes at once; individual submissions will not be accounted for. Please upload
the .java files only.
6. Code on codePost can be uploaded multiple times. The final upload will be considered.
7. Make sure you upload the code before the deadline.