Answer:
{
private String name;
private String review;
/** Constructs a ProductReview object and initializes the instance variables. */
public ProductReview(String pName, String pReview)
{
name = pName;
review = pReview;
}
/** Returns the name of the product. */
public String getName()
{ return name; }
/** Returns the review of the product. */
public String getReview()
{ return review; }
}
The ReviewCollector class, shown below, is used to represent a collection of reviews to be analyzed.
public class ReviewCollector
{
private ArrayList<ProductReview> reviewList;
private ArrayList<String> productList;
/** Constructs a ReviewCollector object and initializes the instance variables. */
public ReviewCollector()
{
reviewList = new ArrayList<ProductReview>();
productList = new ArrayList<String>();
}
/** Adds a new review to the collection of reviews, as described in part (a). */
public void addReview(ProductReview prodReview)
{ /* to be implemented in part (a) */ }
/** Returns the number of good reviews for a given product name, as described in part (b). */
public int getNumGoodReviews(String prodName)
{ /* to be implemented in part (b) */ }
// There may be instance variables, constructors, and methods not shown.
}