Question: language is Java There were two parts to this problem. Please combine both parts into one. Write a Clothing class with the following attributes: color
language is Java
There were two parts to this problem. Please combine both parts into one.
Write a Clothing class with the following attributes:
- color (e.g., "blue", "green", "orange")
- displayName (e.g., "Doctor Who hoodie", "slacks")
- price (e.g., 19.99, 7)
Include only one constructor. It should have parameters for each of the attributes and set their values.
Additionally, include getters and setters for each of the attributes.
Add a driver, name it Purchases, and create 2 Clothing objects.
Finally, print out some information about both objects (i.e., print the information from some or all of the getters). For example, if you created a Clothing object whose color was blue, whose display name was work trousers, for a price of 27.99, you could use the getters to print something like this: These work trousers are blue and cost $27.99. Don't hardcode the print statement for full credit, you must use the getters
In the previous exercise, you created a Clothing object with attributes for the color, display name, and price.
For this exercise, you'll be adding a toString method and an equals method.
Have your toString method return a receipt/purchase order style string of the Clothing object. Here are some examples to give some inspiration or you can simply pick one of these (i.e., it doesn't need to do all of these). The examples assume a Clothing object with color = orange, displayName = T-shirt and price = 19.87:
T-shirt: orange, 19.87 Orange T-Shirt $19.87 T-shirt, orange $19.87
Clothing objects are the same if they have the same color, display name, and price. Write an equals method to represent this.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
