Question Details

(solution) public class TestDealerShip { public static void main (String


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

 

System.out.println

 

System.out.println

 

System.out.println

 

System.out.println (dealer.printReport ());

 

("");

 

(dealer.printAllCarsWithSellingPriceBelow (10000));

 

("");

 

(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 () + "

 

";

 

return list; }

 

public String printAllCarsWithSellingPriceBelow (int price)

 

{

 

price = p;

 

String sellList = "";

 

return sellList;

 

}

 

public String printAllCarsOfColor (String color)

 

{

 

color = c;

 

String colorList = "";

 

for (int i = 0 ; i <= listSize ; i++)

 

{

 

if (cars [i].getPrice () < p)

 

colorList += cars [i].toString ();

 

}

 

return colorList;

 

} }

 

abstract class Car

 

{

 

protected String model;

 

protected int year;

 

protected int price;

 

public Car ()

 

{

 

} public Car (String model, int year, int price)

 

{

 

this.model = model;

 

this.year = year;

 

this.price = price;

 

}

 

public String toString ()

 

{

 

return " Model: " + model

 

+ " Year Made: " + year

 

+ " Price: " + price;

 

}

 

public String getModel ()

 

{

 

return model;

 

}

 

public int getYear ()

 

{

 

return year;

 

}

 

public int getPrice ()

 

{ } return price; public abstract int price ();

 

}

 

class NewCar extends Car

 

{

 

protected String color;

 

public NewCar ()

 

{

 

}

 

public NewCar (String m, int y, int p, String c)

 

{

 

super (m, y, p);

 

color = c;

 

}

 

public int getSellPrice ()

 

{

 

return price;

 

}

 

public String toString ()

 

{

 

String car = super.toString ();

 

return car + " Color: " + color;

 

}

 

public String getColor ()

 

{

 

return color;

 

} public int price ()

 

{

 

// TODO Auto-generated method stub

 

return price;

 

}

 

}

 

class UsedCar extends Car

 

{

 

protected boolean rusty;

 

protected int sellPrice;

 

public UsedCar ()

 

{

 

}

 

public UsedCar (String uM, int uY, int uP, boolean r)

 

{

 

super (uM, uY, uP);

 

this.rusty = r;

 

}

 

public void setReducedPrice (boolean rusty) { if (rusty = true)

 

;

 

sellPrice = super.price - 500; }

 

public String toString ()

 

{

 

String c = super.toString ();

 

return c + " Rusty: " + rusty + " Selling Price: " + sellPrice;

 

} } public int price ()

 

{

 

// TODO Auto-generated method stub

 

return sellPrice;

 

}

 


Solution details:
STATUS
Answered
QUALITY
Approved
ANSWER RATING

This question was answered on: Jan 30, 2021

PRICE: $15

Solution~0001000921.zip (25.37 KB)

Buy this answer for only: $15

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free solution (Deadline assured. Flexible pricing. TurnItIn Report provided)

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Jan 30, 2021

EXPERT

Tutor

ANSWER RATING

GET INSTANT HELP/h4>

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now