blob: 8f0b06e721894631085da8fe57ad4ef7c9f61b93 (
plain)
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
|
package unsw.blackout;
import java.util.Optional;
import unsw.utils.Angle;
import unsw.utils.MathsHelper;
import static unsw.utils.MathsHelper.RADIUS_OF_JUPITER;
public abstract class DeviceBase extends EntityBase {
/**
* DeviceBase is an abstract class containing common functionality between devices.
*/
public DeviceBase(String deviceID, Angle position) {
super(deviceID, position, RADIUS_OF_JUPITER);
}
@ Override
final public double getVelocity() {
return 0.0; // Devices do not move.
}
@ Override
final protected boolean isSupportedEntity(EntityBase entity) {
if (entity instanceof DeviceBase) {
return false;
}
return true;
}
@ Override
final protected boolean isPhysicallyReachable(EntityBase entity) {
if (!(entity instanceof SatelliteBase)) {
return false;
}
if (!MathsHelper.isVisible(entity.getHeight(), entity.getAngle(), this.getAngle())) {
return false;
}
if (MathsHelper.getDistance(entity.getHeight(), entity.getAngle(), this.getAngle()) > this.getRange()) {
return false;
}
return true;
}
final protected Optional<Integer> getFileStoreLimit() {
return Optional.empty(); // Infinite file storage limit.
}
final protected Optional<Integer> getByteStoreLimit() {
return Optional.empty(); // Infinite byte storage limit.
}
final protected Optional<Integer> getByteDownloadSpeed() {
return Optional.empty(); // Infinite download speed
}
final protected Optional<Integer> getByteUploadSpeed() {
return Optional.empty(); // Infinite upload speed.
}
/**
* Adds a file without any bandwidth operation taking place.
*/
void addFile(String filename, String contents) {
this.getReceivedFiles().add(new File(filename, contents, contents.length(), this.getId()));
}
}
|