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 type of memory helps in reading as well as writing data?
Anuta_ua [19.1K]

The read-write type of memory helps in reading as well as writing data. This computer memory is used by users to continually update the data (to access (read from) or alter (write to) ) that is held on hardware storage devices. Internal or external hard disk drives, rewritable CDs or small flash drives can be all physical setups of read-write memory.

6 0
2 years ago
When you are fit, you can exercise and do physical work without getting too tired. A. True B. False\
enot [183]

Answer:

A.

Explanation:

But all of us get tired

3 0
3 years ago
Read 2 more answers
F he continues to make monthly payments of $100, and makes no new purchases, how many more payments will he have to make before
castortr0y [4]

What is the interest rate?

Divide the total amount due by 100.

8 0
3 years ago
The core of ___________ is the implementation of intrusion detection systems and intrusion prevention systems at entry points to
cestrela7 [59]

Answer:

sorry I can't understand what is this is

3 0
2 years ago
Which two approaches optimize test maintenance and support future declarative configuration changes? Choose 2 answers Create a m
patriot [66]

Answer:

B and C

Explanation:

B. Create a method that load valid account records from a static resource, then call this method within test method

C. Create a method that creates valid records, then call this method within test methods

3 0
2 years ago
Other questions:
  • How can you differentiate between standard and protocol? Write at least on example of each of these terminologies?
    12·1 answer
  • NEED HELP FAST
    13·2 answers
  • Which of the following is *not* true about logging user and program actions on a computer?
    10·1 answer
  • What's a sentence with the words trickle and resume in it? they can be in any tense. Thanku​
    5·1 answer
  • Should a waiting thread receive priority over a thread first attempting to enter a monitor? What priority scheme, if any, should
    9·1 answer
  • Find a 95% confidence interval for the mean failure pressure for this type of roof panel.The article "Wind-Uplift Capacity of Re
    7·1 answer
  • HELP AASAP BRAINLIEST JUST HELP
    13·1 answer
  • -- of 5 points Question 3 1 try left While designing a new system, a company uncovered several processes that were quite rule-ba
    6·1 answer
  • Which protocol is well known for its use in the the home security and home automation industry, uses a mesh topology, makes devi
    7·1 answer
  • LIST THE 7 BEST PROGRAMMING MOVIES 2020-2021.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!