-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeamer.java
More file actions
69 lines (62 loc) · 1.72 KB
/
Beamer.java
File metadata and controls
69 lines (62 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Class Beamer - Represents a teleportation device in the game.
*
* It can be charged with a specific room and later fired to teleport
* the player back to the charged room. A beamer can be recharged after use.
*
* The Beamer class extends the {@link Item} class to integrate with the game's item system.
*
* @author Florian NELCHA
*/
public class Beamer extends Item
{
// ### Attributes ###
private Room aChargedRoom;
private boolean aIsCharged;
// ### Constructor ###
/**
* Constructs a new unloaded Beamer with all the attributes of its super class, .
*
* @param pN The name of the Beamer.
* @param pD The description of the Beamer.
* @param pW The weight of the Beamer.
*/
public Beamer(final String pN, final String pD, final double pW)
{
super(pN,pD,pW);
this.aIsCharged = false;
}
// ### Other Methods ###
/**
* Charges the beamer with the given room.
* @param pR The room to charge the beamer with.
*/
public void charge(final Room pR)
{
this.aChargedRoom = pR;
this.aIsCharged = true;
}
/**
* Fires the beamer, returning the charged room.
* @return The room the beamer is charged with, or null if not charged.
*/
public Room fire()
{
if (!this.aIsCharged)
{
return null;
}
Room vTeleportRoom = this.aChargedRoom;
this.aChargedRoom = null;
this.aIsCharged = false;
return vTeleportRoom;
}
/**
* Checks if the beamer is charged.
* @return True if charged, false otherwise.
*/
public boolean isCharged()
{
return this.aIsCharged;
}
}