Question: import java.util.ArrayList; /** * An app store containing apps * * Modifications: * CT: Create AppStore with a list of apps and basic methods to
import java.util.ArrayList;
/** * An app store containing apps * * Modifications: * CT: Create AppStore with a list of apps and basic methods to add, clear, and print apps * * @author Cara Tang * @version 2018.02.17 */ public class AppStore { private String appStoreName; private ArrayList
/** * Find an app based on its name * @param name the name of the app to search for * @return the app with the given name * or null if there is no app with that name */ // public App findApp(String name) // { // TODO: ------------------------ 2 -------------------------- // TODO: Uncomment the method wrapper and implement according to the header comment. // TODO: Do not change the method signature that is given. // TODO: Hint: One approach is to use a for-each to loop over each app in the list. // TODO: Inside the loop check if the app name matches and if so, return the app. // TODO: If the loop completes without returning, the app is not in the list and // TODO: you can return null. // } // TODO: ------------------------ 3 -------------------------- // TODO: Write a method called removeApp that takes a String parameter. // TODO: and removes the app with that name. // TODO: Hint: ArrayList has a remove method that takes an object that is the element // TOOD: to remove. You can call findApp to find the app to remove, and pass it to remove. // TODO: ------------------------ 4 -------------------------- // TODO: Write a method called getAppsByAuthor that takes a String parameter // TODO: and returns a list of apps by the given author. // TODO: If there are no apps with that author, return an empty list (not null). // TODO: Do not print anything in this method. // TODO: Hint: The structure of this method will be the same as the getUnsold method // TODO: from the Auction project. // TODO: ------------------------ 5 -------------------------- // TODO: Write a method called getNumAppsWithRating that takes an int parameter // TODO: representing a rating, and returns the number of apps in the app store // TODO: that have the given rating. // TODO: Example: If two apps in the store have rating 3, then the call // TODO: getNumAppsWithRating(3) will return 2. // OPTIONAL TODO: ------------------------ 6 -------------------------- // OPTIONAL TODO: This TODO is optional. // OPTIONAL TODO: Write a method called getMaxRatingOfAnApp (no parameters) that // OPTIONAL TODO: returns the maximum rating of an app in the app store. // OPTIONAL TODO: Example: If the store has 3 apps, one with rating 2 and two unrated, // OPTIONAL TODO: then the max rating is 2.
// TODO: ------------------------ 7 -------------------------- // TODO: Write a method called printAppStoreSummaryStats (no parameters, no return) // TODO: that prints the name of the app store, the total number of apps, the number of // TODO: apps of each rating, and the number of unrated apps. // TODO: If you implemented getMaxRatingOfAnApp, print the max rating as well. // TODO: Sample output: // ======== SUMMARY STATS for Joe's App Store ======== // Total # of apps: 3 // # apps rated 4: 0 // # apps rated 3: 0 // # apps rated 2: 1 // # apps rated 1: 0 // # of unrated apps: 2 // Max rating: 2 // ===========================================
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
