-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsteroidSize.java
64 lines (58 loc) · 1.57 KB
/
AsteroidSize.java
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
/**
* The AsteroidSize enum defines the different sizes of asteroids in the
* Asteroid Adventure Game. Each size has associated properties like radius
* and points, affecting gameplay dynamics.
*
* @version 1.0
* @since 2023-04-04
*/
public enum AsteroidSize {
SMALL(10, 200),
MEDIUM(20, 100),
LARGE(30, 50);
private final int radius;
private final int points;
/**
* Constructs an AsteroidSize with specified radius and points.
*
* @param radius The radius of the asteroid.
* @param points The points awarded for destroying the asteroid.
*/
private AsteroidSize(int radius, int points) {
this.radius = radius;
this.points = points;
}
/**
* Gets the radius of the asteroid size.
*
* @return The radius of the asteroid.
*/
public int getRadius() {
return this.radius;
}
/**
* Gets the points awarded for destroying the asteroid.
*
* @return The points for the asteroid.
*/
public int getPoints() {
return this.points;
}
/**
* Randomly selects an asteroid size, with each size having an equal probability.
*
* @return A randomly selected AsteroidSize.
*/
public static AsteroidSize randomSize() {
double choice = GameDriver.GENERATOR.nextDouble();
if (choice <= 0.25) {
return AsteroidSize.SMALL;
}
else if (choice >= 0.25 && choice <= 0.50 ) {
return AsteroidSize.MEDIUM;
}
else {
return AsteroidSize.LARGE;
}
}
}