jdalbey

Rope Skeleton

Apr 26th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1. /**
  2.  * A rope is a piece of safety equipment for technical rock climbing.
  3.  * A rope has a name assigned to it by the manufacturer.
  4.  * A rope's fall rating is the number of simulated leader falls
  5.  * the rope holds without breaking during laboratory testing.
  6.  * @author <YOUR NAME HERE>
  7.  * @version Apr 2014
  8.  */
  9. public class Rope
  10. {
  11.     private String name;  // the rope's name
  12.     private int rating;   // the rope's fall rating
  13.    
  14.     /**
  15.      * Construct a rope with the given attributes.
  16.      * @param  name the rope's name
  17.      * @param  rating the rope's rating
  18.      * (Precondition: name contains only letters)
  19.      * (Precondition: rating >= 0)
  20.      */
  21.     public Rope(String name, int rating)
  22.     {
  23.         // PROVIDE METHOD BODY HERE
  24.     }
  25.    
  26.     /**
  27.      * Accessor to rope's name.
  28.      * @return the name of this rope
  29.      */
  30.     public String getName()
  31.     {
  32.         // PROVIDE METHOD BODY HERE
  33.     }
  34.    
  35.     /**
  36.      * Accessor to rope's rating.
  37.      * @return the int rating of this rope
  38.      */
  39.     public int getRating()
  40.     {
  41.         // PROVIDE METHOD BODY HERE
  42.     }
  43.  
  44.     /**
  45.      * Return a printable representation of this rope.
  46.      * @return String representation of the rope's name and rating.
  47.      */
  48.     @Override
  49.     public String toString()
  50.     {
  51.         return name + " " + rating;
  52.     }
  53.    
  54.     /** Return whether or not this rope is certified by UIAA.
  55.      * The rope must have a fall rating of at least 5 to be certified.
  56.      * @return true if this rope's rating >= 5, false otherwise.
  57.      */
  58.     public boolean isCertified()
  59.     {
  60.         // PROVIDE METHOD BODY HERE
  61.     }
  62.        
  63.     /** Determine if two ropes are the same.
  64.      * @param other the rope to whom this rope is compared
  65.      * @return true if ropes are equal
  66.      */
  67.     @Override
  68.     public boolean equals(Object other)
  69.     {
  70.         if (other instanceof Rope)
  71.         {
  72.             Rope candidate = (Rope) other;
  73.             return this.name.equals(candidate.name);
  74.         }
  75.         return false;
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment