1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zavuch27 [327]
3 years ago
14

Write the getNumGoodReviews method, which returns the number of good reviews for a given product name. A review is considered go

od if it contains the string "best" (all lowercase). If there are no reviews with a matching product name, the method returns 0. Note that a review that contains "BEST" or "Best" is not considered a good review (since not all the letters of "best" are lowercase), but a review that contains "asbestos" is considered a good review (since all the letters of "best" are lowercase). Complete method getNumGoodReviews. /** Returns the number of good reviews for a given product name, as described in part (b). */ public int getNumGoodReviews(String prodName)
Computers and Technology
1 answer:
Naya [18.7K]3 years ago
3 0

Answer:

Check the explanation

Explanation:

ProductReview.java

public class ProductReview {

  private String name;

  private String review;

 

  public ProductReview(String name, String review) {

      super();

      this.name = name;

      this.review = review;

  }

  public String getName() {

      return name;

  }

  public String getReview() {

      return review;

  }

 

 

}

ReviewCollector.java

import java.util.ArrayList;

public class ReviewCollector {

  private ArrayList<ProductReview> reviewList;

  private ArrayList<String> productList;

  public ReviewCollector(ArrayList<ProductReview> reviewList, ArrayList<String> productList) {

      super();

      this.reviewList = reviewList;

      this.productList = productList;

  }

  public void addReview(ProductReview prodReview) {

      this.reviewList.add(prodReview);

  }

  public int getNumGoodReviews(String prodName) {

      int count = 0;

      ArrayList<ProductReview> set = new ArrayList<>();

      for (int i = 0; i < reviewList.size(); i++) {

          if (reviewList.get(i).getName().compareToIgnoreCase(prodName) == 0) {

              set.add(reviewList.get(i));

          }

      }

      if(set.size()==0)

          return count;

     

      for (int i = 0; i < set.size(); i++) {

          if (set.get(i).getReview().contains("best")) {

              count++;

          }

      }

      return count;

  }

}

You might be interested in
Which statement regarding hard drives is incorrect?
Veseljchak [2.6K]

Answer: I think the answer is

c. solid state drives are less expensive than magnetic hard drives

Explanation:

4 0
2 years ago
Read 2 more answers
Question 17 (3 points)
Archy [21]

Answer:

#

Explanation:

6 0
3 years ago
CONCEPTO DE ORGANIGRAMA
inysia [295]
Como the amas si mucho gusto
3 0
2 years ago
Why would advertising be more important in a magazine publishing than it is in a newspaper?
Bond [772]
Newspapers are irrelevant now, magazines will get you much more viewers.
3 0
3 years ago
Read 2 more answers
A template class is a class in which ___________.
Romashka [77]

Answer: (A) At least one type is parameterized

Explanation:

 A template class is the type of class in which the one type are parameterized atleast in each template class. The template class mainly provide the various type of specifications so that it can generate the class based on the different types of parameters.

A template class is basically initialized by passing the template argument in the given types. In this type of class atleast one type is defined as the generic type.

Therefore, Option (A) is correct.

6 0
2 years ago
Read 2 more answers
Other questions:
  • Matt wants to build an app that will reach many people all over the world. However, he worries about having to modify apps for a
    14·1 answer
  • Who is the CEO of Quora?
    15·1 answer
  • A technician, joe, has replaced a faulty 500 gb hard drive in a pc system with a 1 tb hard drive. however, after the replacement
    10·1 answer
  • Question 1(Multiple Choice Worth 2 points)<br> Which of the following is true of a good photograph?
    10·2 answers
  • Which statement is true?
    5·2 answers
  • Which type of chart is used to chart progress over time?
    10·1 answer
  • A(n) ________ CPU has two processing paths, allowing it to process more than one instruction at a time.
    9·2 answers
  • John was carrying on at the water cooler the other day, trying to show off his knowledge of networking. He claimed that the comp
    10·1 answer
  • The Coins class was created to hold all your loose change, kind of like a piggy bank! For this exercise, you are going to simula
    15·1 answer
  • Literally no one helps answer my questions so this website is pointless.... : /
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!