Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * A rope is a piece of safety equipment for technical rock climbing.
- * A rope has a name assigned to it by the manufacturer.
- * A rope's fall rating is the number of simulated leader falls
- * the rope holds without breaking during laboratory testing.
- * @author <YOUR NAME HERE>
- * @version Apr 2014
- */
- public class Rope
- {
- private String name; // the rope's name
- private int rating; // the rope's fall rating
- /**
- * Construct a rope with the given attributes.
- * @param name the rope's name
- * @param rating the rope's rating
- * (Precondition: name contains only letters)
- * (Precondition: rating >= 0)
- */
- public Rope(String name, int rating)
- {
- // PROVIDE METHOD BODY HERE
- }
- /**
- * Accessor to rope's name.
- * @return the name of this rope
- */
- public String getName()
- {
- // PROVIDE METHOD BODY HERE
- }
- /**
- * Accessor to rope's rating.
- * @return the int rating of this rope
- */
- public int getRating()
- {
- // PROVIDE METHOD BODY HERE
- }
- /**
- * Return a printable representation of this rope.
- * @return String representation of the rope's name and rating.
- */
- @Override
- public String toString()
- {
- return name + " " + rating;
- }
- /** Return whether or not this rope is certified by UIAA.
- * The rope must have a fall rating of at least 5 to be certified.
- * @return true if this rope's rating >= 5, false otherwise.
- */
- public boolean isCertified()
- {
- // PROVIDE METHOD BODY HERE
- }
- /** Determine if two ropes are the same.
- * @param other the rope to whom this rope is compared
- * @return true if ropes are equal
- */
- @Override
- public boolean equals(Object other)
- {
- if (other instanceof Rope)
- {
- Rope candidate = (Rope) other;
- return this.name.equals(candidate.name);
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment