1 |
/** |
2 |
A class that describes the effects of an earthquake. |
3 |
*/ |
4 |
public class Earthquake |
5 |
{ |
6 |
/** |
7 |
Constructs an Earthquake object. |
8 |
@param magnitude the magnitude on the Richter scale |
9 |
*/ |
10 |
public Earthquake(double magnitude) |
11 |
{ |
12 |
richter = magnitude; |
13 |
} |
14 |
|
15 |
/** |
16 |
Gets a description of the effect of the earthquake. |
17 |
@return the description of the effect |
18 |
*/ |
19 |
public String getDescription() |
20 |
{ |
21 |
String r; |
22 |
if (richter >= 8.0) |
23 |
r = "Most structures fall"; |
24 |
else if (richter >= 7.0) |
25 |
r = "Many buildings destroyed"; |
26 |
else if (richter >= 6.0) |
27 |
r = "Many buildings considerably damaged, some collapse"; |
28 |
else if (richter >= 4.5) |
29 |
r = "Damage to poorly constructed buildings"; |
30 |
else if (richter >= 3.5) |
31 |
r = "Felt by many people, no destruction"; |
32 |
else if (richter >= 0) |
33 |
r = "Generally not felt by people"; |
34 |
else |
35 |
r = "Negative numbers are not valid"; |
36 |
return r; |
37 |
} |
38 |
|
39 |
private double richter; |
40 |
} |