Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Inheritance and Polymorphism: SuperClass Create a superclass Clothing Define properties size and color Include methods wash(), pack() For each method return a string that included
Inheritance and Polymorphism: SuperClass
Create a superclass Clothing
- Define properties size and color
- Include methods wash(), pack()
- For each method return a string that included instructions, for example, "Wash in cold water"
- Your tester will have have to print the string to test these methods.
Create 2 derived classes from Clothing class:
- Pants class
- Write necessary constructors
- Override the wash() method to indicate that pants are dry clean only.
- Include additional method hang()
- Add to your driver/tester file to make and print new pants objects and test it.
- Shirt class
- Include additional property of type string called sleeves.
- Write necessary constructors
- For sleeves only allow it to be set to {"short", "long", "none"}
- For size, only allow {"S","M","L"}
- Override the wash() method to indicate that shirts are dry clean only.
- Include additional method hang()
- Add to your driver/tester file to make and print new Shirt objects and test it.
-
Test your file
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started