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]
4 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]4 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
Help please i will give Brainliest
steposvetlana [31]

Answer:

ok I've got the answer sheet on the picture I will attach

Explanation:

I had to crop to size on my computer and found them all

8 0
3 years ago
Effective note-taking helps support<br><br> action.<br> distinction.<br> distraction.<br> retention.
zloy xaker [14]
It is the last one retention because writing it out will cause it to stick in your brain better
7 0
3 years ago
Read 2 more answers
So I'm a teen computer programmer, and I've built a couple of projects, but I'm looking for an idea to make me big money. So fel
Juliette [100K]
I hate lag and glitch and so many adds
5 0
3 years ago
Help!! me!! plsssssssssssssssssssssssssssssssssss
Maslowich

Answer:

e,f,g, and h

Explanation:

5 0
3 years ago
Which type of document would be best created in Word? HELLP!!!!
bekas [8.4K]
I think it’s presentation.
Like if I am right.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which tool should Jules use to encourage her reader's interaction on her website? Jules should use the ________ tool to encourag
    5·1 answer
  • What output is produced by the following code fragment int num = 1 max = 20 while num &lt; max?
    7·1 answer
  • Which of the following functions sends the the GPA entered by the user to the calling function? A. def get_gpa(): gpa = float(in
    8·1 answer
  • Anna wants to keep information secure from offenders. Which software should she install on her computer to ensure Internet safet
    13·1 answer
  • In a relational database, the three basic operations used to develop useful sets of data are:_________.
    14·1 answer
  • What is the deffirentiates in organs from tissues
    11·1 answer
  • Calculator is an example of
    14·1 answer
  • You develop an app, and you don’t want anyone to resell it or modify it. This is an example of: A
    5·1 answer
  • Which three IP addresses may be pinged by the Test Management Network feature in the ESXi hosts DCUI
    12·1 answer
  • if prakash gives one of the marble from what he possessses to kamala then they will have equal number of marbles.if kamala gives
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!