Introduction
This lab is designed to give you some experience with user input as well as with implementing a program that involves more than one class.
The ProductReview class
You should implement a class with the following properties:
- Maintains a productName, averageStarRating, numberOfPeopleRating, and comments.
- The constructor should accept exactly the productName as an argument
- Each time the rateProduct method is called, the averageStarRating and numberOfPeopleRating should be to reflect the new rating provided as an argument. The averageStarRating can be fractional. This method should return false if the new rating is not within the range: 0 <= rating <= 5. Otherwise, it should return true.
- Each time the addComment method is called, the provided new comment should be appended to the list of comments, one per line. This method should return false if the comment is null or the empty string and true, otherwise.
- All properties should be accessible via getter methods.
- There should be a isBetter method that returns true if, and only if, this product has a better rating than the one referenced by the argument.
- The equals(...) and toString(...) methods should be implemented
The Test Driver
As has been the case in the past, the ProductReview class should contain a main() method that acts as a thorough test driver
The InteractiveTest class
In addition to the ProductReview class, you should implement an InteractiveTest class. This class should contian nothing more than a main method. This main method should be interactive. It should prompt the user for a product name, star rating, and comment. It should then, consistent with this input, initialize an instance of the ProductReview class, rate it, and add a comment. It should print out the newly prepared object to prove that it works. Please note: the user should be appropriately prompted for all input.
About Multiple main() Methods
Multiple main() methods can exist. In this case, we have two: One within the ProductReview class and another within the InteractiveTest class. Each of these classes needs to be compiled. Either one at a time or on the same command line. But, only one of the two main methods needs to be run. So, "java ProductReview" will run the test driver, but "java InteractiveTest" will run the simple program that solicits input from the user in order to create the ProductReview.