Question: 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

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!