-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathAsteroid.java
75 lines (61 loc) · 2 KB
/
Asteroid.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
65
66
67
68
69
70
71
72
73
74
75
import java.util.Date;
public class Asteroid {
private String name;
private Date approach_date;
private Double diameter, missing_approach;
private boolean isHazardous;
public Asteroid(){}
/**
* @param name Asteroid Name
* @param date Asteroid's approaching date
* @param diameter Asteroid's diameter
* @param missing_approach Asteroid's approaching distance in km
* @param isHazardous A boolean represents if asteroid hazardous
*/
public Asteroid(String name, Date date, Double diameter, Double missing_approach, boolean isHazardous){
this.name = name;
this.approach_date = date;
this.diameter = diameter;
this.missing_approach = missing_approach;
this.isHazardous = isHazardous;
}
public Date getApproach_date() {
return approach_date;
}
public void setApproach_date(Date approach_date) {
this.approach_date = approach_date;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getDiameter() {
return diameter;
}
public void setDiameter(Double diameter) {
this.diameter = diameter;
}
public Double getMissing_approach() {
return missing_approach;
}
public void setMissing_approach(Double missing_approach) {
this.missing_approach = missing_approach;
}
public boolean isHazardous() {
return isHazardous;
}
public void setHazardous(boolean hazardous) {
isHazardous = hazardous;
}
@Override
public String toString() {
return "Asteroid "+ name
+ " with diameter "+ diameter
+ " approached to world on " + approach_date.toString()
+ " from the distance of " + missing_approach
+ (missing_approach==1.0 ? " kilometer" : " kilometers") + " and this asteroid is "
+ (isHazardous? "hazardous." : "not hazardous.");
}
}