Question: Java: complete and fully test the class Characteristic that excercise 5 descirbes. Excercise 5: - description - a string thay identifies the characteristic - rating
Java:
complete and fully test the class Characteristic that excercise 5 descirbes.
Excercise 5:
- description - a string thay identifies the characteristic
- rating - an integer between 1 and 10 that identifies 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 insisiting that the rating supplied by the user be valid.
Include the following methods:
- getDescription - returns the description of this characteristic.
- getRating - returns the rating of this characteristic.
- getCompatability(Characteristic otherRating) - returns the compatability measure of two matching characteristics, or zero if the descriptions do not match.
- getCompatabilityMeasure(Characteristic otherRating) - a private method that returns a compatability measure as a double value using the formula:
[ m = 1- ((r1-r2)^2) / (81)]
when both ratings are nonzero; m is zero if either rating is zero. (Recall from excercise 5 that the constructor sets the rating to zero, indicating that it has not yet been determined.)
- isMatch(Characteristic otherRating) - a private method that returns true if the descriptions match.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
