COMP2396
Loading...
Searching...
No Matches
assignment2.BadGun Class Reference

The BadGun has poor quality such that at each shot, only 80% of its original power can be produced (round down to the nearest integer). More...

Inheritance diagram for assignment2.BadGun:
Collaboration diagram for assignment2.BadGun:

Public Member Functions

 BadGun (String name, int power)
 Constructs a new BadGun with the specified name and power level.
 
int shoot ()
 Shoots the gun and returns 80% of the original power (rounded down).
 
- Public Member Functions inherited from assignment2.Weapon
 Weapon (String name, int power)
 Constructs a new Weapon with the specified name and power level.
 
String getName ()
 Returns the name of the weapon.
 

Detailed Description

The BadGun has poor quality such that at each shot, only 80% of its original power can be produced (round down to the nearest integer).

It is a subclass of the Weapon class and only produces 80% of the original power.

Definition at line 8 of file BadGun.java.

Constructor & Destructor Documentation

◆ BadGun()

assignment2.BadGun.BadGun ( String name,
int power )
inline

Constructs a new BadGun with the specified name and power level.

Parameters
namethe name of the bad gun
powerthe power level of the bad gun

Definition at line 16 of file BadGun.java.

16 {
17 super(name, power);
18 }
final int power
Definition Weapon.java:9

References assignment2.Weapon.power.

Member Function Documentation

◆ shoot()

int assignment2.BadGun.shoot ( )
inline

Shoots the gun and returns 80% of the original power (rounded down).

Returns
the power generated by the weapon

Reimplemented from assignment2.Weapon.

Definition at line 26 of file BadGun.java.

26 {
27 return (int) Math.floor(super.shoot() * 0.8);
28 }

The documentation for this class was generated from the following file: