Consider a class Characteristic that will be used in an online dating service to assess how compatible

Question:

Consider a class Characteristic that will be used in an online dating service to assess how compatible two people are. Its attributes are

  • description—a string that identifies the characteristic
  • rating—an integer between 1 and 10 that indicates a person’s desire for this characteristic in another person

a. Write a constructor that sets the description of the characteristic to a given string and sets the rating to zero to indicate that it has not yet been determined.

b. Write a private method isValid(aRating) that returns true if the given rating is valid, that is, is between 1 and 10.

c. Write a method setRating(aRating) that sets the rating to aRating if it is valid.

d. Write a method setRating that reads a rating from the keyboard, insisting that the rating supplied by the user be valid.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: