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 of the following criteria would not make a person eligible to receive medicare benefits?Which of the following criteria wo
Mumz [18]
B terminal illness .....
4 0
3 years ago
Read 2 more answers
Assume the variable sales references a float value. Write a statement that displays the value rounded to two decimal points.Assu
romanna [79]

Answer:

The statement is as follows:

print("{0:,.1f}".format(number))

Explanation:

Required

Statement to print 1234567.456 as 1,234,567.5

To do this, we make use of the format keyword, and we set the print format in the process.

To round up number to 1 decimal place, we use the following format:

"{0:,.1f}"

To include comma in the thousand place, we simply include a comma sign before the number of decimal place of the output; i.e. before 1

"{0:,.1f}"

So, the print statement is:

print("{0:,.1f}".format(number))

3 0
3 years ago
How do I get rid of this little tool bar????
Serhud [2]

Answer:

settings>Accessibility>Touch>AssistiveTouch>Turn off

Explanation:

4 0
3 years ago
Sonora wants to extend the cells to be added in her formula. What is the quickest way to add more cells?
djyliett [7]

Answer:

D

Explanation: took the test on edge

7 0
3 years ago
Read 2 more answers
Consider Ron’s budget. How much money does Ron have left over each month?
vladimir1956 [14]
What is Ron’s budget?
4 0
3 years ago
Read 2 more answers
Other questions:
  • Write a MIPS assembly language program that prompts for a user to enter how many floating point numbers to enter, then prompts t
    10·1 answer
  • What is <br> Warehouse schema.
    14·1 answer
  • If johnny has 800 socks and john has 1000 more how much does john have
    9·1 answer
  • What education and training is required to be an applications software engineer?
    9·1 answer
  • What type of program would you use to create a personal budget?
    9·1 answer
  • Write a method called printRange that accepts two integers as arguments and prints the sequence of numbers between the two argum
    6·1 answer
  • How should a Salesforce Admin fulfill those requirements? Universal Containers launches a Partner Community for their resellers
    13·1 answer
  • What does the revolver do computer science​
    9·1 answer
  • Modern life is not possible if computer stops working? Give your opinion<br>​
    7·1 answer
  • When adding a component to a container with the ____ layout, specify the NORTH, EAST, SOUTH, WEST, or CENTER position.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!