Complete and fully test the class Characteristic that Exercise describes Include the following methods:
• getDescription—returns the description of this characteristic.
• getRating—returns the rating of this characteristic.
• getCompatability(Characteristic otherRating)—returns the compatibility measure of two matching characteristics, or zero if the descriptions do not match.
• getCompatibilityMeasure(Characteristic otherRating)—a private method that returns a compatibility measure as a double value using the formula
when both ratings are nonzero; m is zero if either rating is zero. (Recall from Exercise 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.
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.
Exercise 5
Write a Java enumeration LetterGrade that represents letter grades A through F, including plus and minus grades. Define a private instance variable to hold a boolean value that is true if the grade is passing. Also, define a constructor that initializes this instance variable, an accessor method isPassing to return its value, and a method toString that returns the grade as a string. Finally, write a program to demonstrate the enumeration.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.