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

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.

Step by Step Solution

3.38 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Characteristic private String descriptio... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java An Introduction to Problem Solving and Progra Questions!