Menu

[Solved]Create New Project Bluej Name Lastname Lab2 App Eg Smith Lab2 App Create New Class Using N Q37196460

  1. Create a new project in BlueJ and name it LastName-lab2-app,e.g., Smith-lab2-app.
  2. Create a new class using the “New Class…” button and name itApp (be sure the A is capitalized and the other letters are not;Java is case-sensitive and the class must be named exactly asgiven).
  3. Open the App class to edit the source code.
  4. Select and delete all the source code so that the fileis empty.
  5. Copy in the starting source code found here: Lab 2: AppStarting Source Code
  6. Update the header comment block and document your changes asyou work.
    • Adjust the header comment block at the top of the file:
      *
      * Modifications:
      * …
      * CT: Added method to print app basic info
      * YN: … ← List changes you make prefaced by yourinitials
      *
      * @author Cara Tang, Your Name ← Add your name
      * @version 2017.12.30 ← Update the version to the currentdate
      */
    • Whenever you add a new method, include a documentation blockthat describes what the method does. For example:
      /**
      * Return the app rating
      */
  7. Complete the TODOs in the code, modifying and implementingmethods as described. Be sure to follow the specifications as givenin the TODO comments, for example the methods must be named asgiven (with correct spelling and capitalization).
  8. Before submitting your project, delete the TODO comments. TODOsrepresent a task that still needs to be done, and when you completea TODO it should be removed. There should not be anyTODOs in your submitted project(unless you didn’tcomplete the project).
  9. Adhere to Java style guidelines as described in AppendixJ.

import java.util.ArrayList;

import java.util.List;

/**

* An app store containing apps

*

* Modifications: CT: Create AppStore with a list of apps andbasic methods to

* add, clear, and print apps

*

* @author Cara Tang

* @version 2018.02.17

*/

public class AppStore {

private String appStoreName;

private Array List;

private App List;

public AppStore() {

}

/**

* Create an app store with the given name

*

* @param name

* the name of this app store

*/

public AppStore(String name) {

appStoreName = name;

appList = new ArrayList();

}

/**

* Populate the store with a few apps. Use this method to maketesting

* easier. After creating an AppStore, call this method topopulate the

* apps, and then test your methods.

*/

public void populateApps() {

// TODO: ———————— 1————————–

addApp(“Pandora Music”, “Pandora”, 0);

addApp(“Pandora Music”, “Pandora”, 0);

addApp(“Pandora Music”, “Pandora2”, 0.25,5);

addApp(new App(“Minecraft”, “Mojang”, 6.99, 3));

addApp(new App(“Minecraft”, “Mojang”, 3));

addApp(new App(“Minecraft”, “Mojang2”, 3));

addApp(new App(“Minecraft”, “Mojang3”, 3));

addApp(new App(“Minecraft”, “Mojang4”, 3));

addApp(new App(“Minecraft”, “Mojang5”, 3));

addApp(new App(“TempleRun”, “TempleRun1”, 6.99, 3));

addApp(new App(“TempleRun”, “TempleRun2”, 3));

addApp(new App(“TempleRun”, “TempleRun3”, 3));

}

/**

* Add the given app to the app store

*

* @param anApp

* an app to add

*/

public void addApp(App anApp) {

appList.add(anApp);

}

/**

* Create an app with the given name, author, and price and addit to the

* store. The app starts out unrated.

*

* @param name

* name of the app

* @param author

* the app author

* @param price

* the price of the app

*/

public void addApp(String name, String author, double price){

appList.add(new App(name, author, price));

}

/**

* Create an app with the given name, author, price and ratingand add it to the

* store.

*

* @param name

* name of the app

* @param author

* the app author

* @param price

* the price of the app

*/

public void addApp(String name, String author, double price,intrating) {

appList.add(new App(name, author, price, rating));

}

/**

* @return the number of apps in the store

*/

public int getNumberOfApps() {

return appList.size();

}

/**

* Removes all the apps from the store

*/

public void clearAppStore() {

appList.clear();

}

/**

* Print all the apps in the store

*/

public void printAppList() {

System.out.println(“============= ” + appStoreName + “=============”);

if (appList.size() == 0) {

System.out.println(“No apps in the store”);

} else {

System.out.println(“AppName Author Price Rating”);

for (App currentApp : appList) {

System.out.println(currentApp.getName()+””+currentApp.getAuthor()+” $”+currentApp.getPrice()+””+currentApp.getRating());

}

}

System.out.println(“===========================================”);

}

/**

* 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 appwith that

* name

*/

public App findApp(String name){

if(name !=null && name.length()!=0){

for (App thisApp : appList) {

if(thisApp.getName().equalsIgnoreCase(name)){

return thisApp ;

}

}

}

return null;

}

/**

* Remove an app based on its name

*

* @param name

* the name of the app to remove

* @return the app with the given name or null if there is no appwith that

* name

*/

public int removeApp(String name){

if(name !=null && name.length()!=0){

App appToRemove = findApp(name);

if(appToRemove !=null){

appList.remove(appToRemove);

}

}

return 0;

}

/**

* Returns all apps by author’s name

*

* @param name

* the name of the app to remove

* @return the app with the given name or null if there is no appwith that

* name

*/

public List getAppsByAuthor(String authorName){

List appsByAuthor = new ArrayList();

if(authorName !=null && authorName.length()!=0){

for(App x : appList){

if(x.getAuthor().equalsIgnoreCase(authorName)){

appsByAuthor.add(x);

}

}

}

return appsByAuthor;

}

/**

* Returns the number of apps in the appstore with the givenrating

*

* @param rating

* integer

* @return the count of apps in the appstore with the givenrating

*/

public int getNumAppsWithRating(int rating){

int countOfAppsWithGivenRating = 0;

if(rating >=0 && rating <=5){

for(App x : appList){

if(x.getRating()== rating){

countOfAppsWithGivenRating++;

}

}

}

return countOfAppsWithGivenRating;

}

/**

* Prints the name of the app store, the total number ofapps,

* the number of apps of each rating, and the number of unratedapps.

* @param rating

* integer

* @return the count of apps in the appstore with the givenrating

*/

public void printAppStoreSummaryStats(){

System.out.println(“======== SUMMARY STATS for”+this.appStoreName+” ========”);

int countRating5 =0;

int countRating4 =0;

int countRating3 =0;

int countRating2 =0;

int countRating1 = 0;

int countNoRating =0;

System.out.println(“Total # of apps : “+getNumberOfApps());

for(App x : appList){

if(x.getRating()==5)countRating5++;

else if(x.getRating()==4)countRating4++;

else if(x.getRating()==3)countRating3++;

else if(x.getRating()==2)countRating2++;

else if(x.getRating()==1)countRating1++;

else countNoRating++;

}

System.out.println(“# apps rated 5 : “+countRating5 );

System.out.println(“# apps rated 4 : “+countRating4 );

System.out.println(“# apps rated 3 : “+countRating3 );

System.out.println(“# apps rated 2 : “+countRating2 );

System.out.println(“# apps rated 1 : “+countRating1 );

System.out.println(“# of unrated apps : “+countNoRating );

System.out.println(“===========================================”);

}

public static void main(String[] args) {

AppStore appStore = new AppStore(“Joe’s App Store”);

appStore.populateApps();

appStore.printAppList();

appStore.printAppStoreSummaryStats();

}

}

there are 37 Errors please help me with code

public App findApp(String name) if (name null &&name.length)!-0) for (App thisApp appList) if (thisApp.getName().equalsIgnoreif (appToRemovenull)( appList.remove (appToRemove) return 0; *Returns all apps by authors name * @param name * the name of te dpp name public List<App> getAppsByAuthor (String authorName){ List appsByAuthornew ArrayList<App>(); İf (authorName !-nu11return appsByAuthor; *Returns the number of apps in the appstore with the given rati * @param rating * integer *@return the c치 public int getNumAppsWithRating(int rating) int countOfAppsWithGivenRating0; if (rating > && rating <-5) for(App x : applispublic void printAppStoreSummaryStats) System.out.println(SUMMARY STATS for +this.appStoreName+ int countRating5 =0; intelse countNoRating++; System . out.println(# apps rated 5 : +countRating5 ); System.out.printIn(# apps rated 4 : +countRa

public App findApp(String name) if (name null &&name.length)!-0) for (App thisApp appList) if (thisApp.getName().equalsIgnoreCase (name)) ( return thisApp; return null; if (appToRemovenull)( appList.remove (appToRemove) return 0; *Returns all apps by author’s name * @param name * the name of the app to remove e dpp name public List<App> getAppsByAuthor (String authorName){ List appsByAuthornew ArrayList<App>(); İf (authorName !-nu11 && authorName.length() !-e){ for (App x : appList) if(x.getAuthor ().equalsIgnoreCase(authorName)) appsByAuthor.add(x); return appsByAuthor; *Returns the number of apps in the appstore with the given rati * @param rating * integer *@return the count of apps in the appstore with the given rating 치 public int getNumAppsWithRating(int rating)< int countOfAppsWithGivenRating = 0; if(rating >&& rating <-5)f 치 public int getNumAppsWithRating(int rating) int countOfAppsWithGivenRating0; if (rating > && rating <-5) for(App x : applist)( if(x.getRating()-= rating){ countofAppsWithGivenRating++; return countOfAppsWithGivenRating public void printAppStoreSummaryStats) System.out.println(“SUMMARY STATS for “+this.appStoreName+”” int countRating5 =0; int countRating4 -0; int countRating3 int countRating2 int countRating1 0; int countNoRating0 System.out, printin (.. Total # of apps : ,, +getNumberOfApps()); for (App x applist) if (x.getRating()5)countRating5++; else if(x.getRating()4untRating4++; else if(x.getRating()3)cuntRating3++; else if(x.getRating()2)cuntRating2++; else if(x.getRating)1)countRating1++; else countNoRating++ else countNoRating++; System . out.println(“# apps rated 5 : “+countRating5 ); System.out.printIn(“# apps rated 4 : “+countRating4 ); System.out.print1n(“# apps rated 3 : “+countRating? ); System . out.println(“# apps rated 2 : “+countRating2 ); System.out.printin(“# apps rated 1 : “+countRating1 ); System . out.println(“# of unrated apps : “+countNoRating ); System. out. println(” “): public static void main(Stringl args) f AppStore appStore – new AppStore(“Joe’s App Store”); appStore.populateApps() appStore.printAppList) appStore.printAppStoreSummaryStats(); Show transcribed image text public App findApp(String name) if (name null &&name.length)!-0) for (App thisApp appList) if (thisApp.getName().equalsIgnoreCase (name)) ( return thisApp; return null;
if (appToRemovenull)( appList.remove (appToRemove) return 0; *Returns all apps by author’s name * @param name * the name of the app to remove
e dpp name public List getAppsByAuthor (String authorName){ List appsByAuthornew ArrayList(); İf (authorName !-nu11 && authorName.length() !-e){ for (App x : appList) if(x.getAuthor ().equalsIgnoreCase(authorName)) appsByAuthor.add(x);
return appsByAuthor; *Returns the number of apps in the appstore with the given rati * @param rating * integer *@return the count of apps in the appstore with the given rating 치 public int getNumAppsWithRating(int rating)&& rating && rating

Expert Answer


Answer to Create a new project in BlueJ and name it LastName-lab2-app, e.g., Smith-lab2-app. Create a new class using the “New Cla… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *