Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 12 Weeks Ago, 5 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I need help with this assignment, specifically the printReport, String printAllCarsOfColor and printAllCarsWithSellingPriceBelow
Â
public class TestDealerShip{public static void main (String[] args){CarDealerShip dealer = new CarDealerShip ();dealer.addNewCar ("GM Buick Century", 2004, 20000, "Silver");dealer.addUsedCar ("Toyota Corolla", 1999, 9000, true);dealer.addNewCar ("Honda Civic", 2004, 15000, "Green");dealer.addNewCar ("BMW 320i", 2004, 35000, "Black");dealer.addUsedCar ("Toyota Sienna", 2000, 11000, false);System.out.println (dealer.printReport ());System.out.println ("");System.out.println (dealer.printAllCarsWithSellingPriceBelow (10000));System.out.println ("");System.out.println (dealer.printAllCarsOfColor ("Green"));}}class CarDealerShip{private String m;private int y;private int p;private String c;int listSize;Car[] cars;boolean r;public CarDealerShip (){cars = new Car [80];listSize = 0;}public void addNewCar (String model, int year, int price, String color){m = model;y = year;p = price;c = color;cars [listSize] = new NewCar (m, y, p, c);listSize++;}public void addUsedCar (String model, int year, int price, boolean rusty){m = model;y = year;p = price;r = rusty;cars [listSize] = new UsedCar (m, y, p, r);listSize++;}public String printReport (){String list = "";for (int i = 0 ; i <= listSize ; i++)list += cars [i].toString () + "\n";return list;