Description: likes sports is rated as 7 Description: likes beaches is rated as 0 What is your rating for likes sports? P
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Description: likes sports is rated as 7 Description: likes beaches is rated as 0 What is your rating for likes sports? P
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 1. 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. 2. Write another constructor that sets the rating to a given rating (if it is valid - call the isValid method) and sets the description to "No description yet" to indicate that it has not yet been determined. 3. Write another constructor that sets both description and rating to a given description and rating (if it is valid). 4. Write a private method isValid (aRating) that returns true if the given rating is valid, that is, is between 1 and 10. 5. Write a method setRating that reads a rating from the keyboard, insisting that the rating supplied by the user be valid. 6. Write a toString method that return the description and rating. 7. Write suitable accessors and mutators methods. A sample output of the program is given below: