COMP2396
Loading...
Searching...
No Matches
BadGun.java
Go to the documentation of this file.
1package assignment2;
2
3/**
4 * The BadGun has poor quality such that at each shot, only 80% of its original
5 * power can be produced (round down to the nearest integer).
6 * It is a subclass of the Weapon class and only produces 80% of the original power.
7 */
8public class BadGun extends Weapon {
9
10 /**
11 * Constructs a new BadGun with the specified name and power level.
12 *
13 * @param name the name of the bad gun
14 * @param power the power level of the bad gun
15 */
16 public BadGun(String name, int power) {
17 super(name, power);
18 }
19
20 /**
21 * Shoots the gun and returns 80% of the original power (rounded down).
22 *
23 * @return the power generated by the weapon
24 */
25 @Override
26 public int shoot() {
27 return (int) Math.floor(super.shoot() * 0.8);
28 }
29}
The BadGun has poor quality such that at each shot, only 80% of its original power can be produced (r...
Definition BadGun.java:8
BadGun(String name, int power)
Constructs a new BadGun with the specified name and power level.
Definition BadGun.java:16
int shoot()
Shoots the gun and returns 80% of the original power (rounded down).
Definition BadGun.java:26
The Weapon class represents any game weapon with a name and power level.
Definition Weapon.java:7
final int power
Definition Weapon.java:9