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