Question: ***MUST BE IN JAVA*** Create a new driver for your Clothing and Sweatshirt classes. In this driver: - Create an ArrayList of Clothing objects -

***MUST BE IN JAVA***

Create a new driver for your Clothing and Sweatshirt classes. In this driver: - Create an ArrayList of Clothing objects - Add at least 2 of each, Clothing and Sweatshirt, to the ArrayList - Loop through the ArrayList, printing each object in the list to make polymorphism work for you!

HERE IS THE PREVIOUS CODE USED BELOW

public class Clothing { String color; double price; public Clothing( String color, double price) { this.color = color; this.price = price; } public String toString() { return color+" $"+price; }

}

SECOND PIECE OF CODE:

public class Sweatshirt extends Clothing { String size; boolean isHooded; String brandName;

public Sweatshirt(String brandName, boolean isHooded, String color, double price, String size) { super(color, price); this.size = size; this.isHooded = isHooded; this.brandName = brandName; } public String toString() { if (isHooded) { return size + " " + brandName + " hoodie, " + super.toString(); } else { return size + " " + brandName + " sweatshirt, " + super.toString(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!