DYNAMIC BINDING, FINAL AND EXCEPTION HANDLING

This task is about dynamic binding, final and exception-handling

Important: incomplete, wrong (unnecessary setter, visibility, no exception handling, no equals, no hashCode, no use of final) or uncommented code will result in 0 points.

Implement a class Garderobe with this attributes:

  • Name
  • Owner
  • Capacity
  • List of all clothes in this Garderobe. (Garderobe may be empty, but can't hold more Items than Capacity!

Every attribute except the list of clothes must be determined in the constructor. These must be private.

Implement the Interface Clothing with these attributes:

  • Name
  • Color
  • Shop
  • ItemNumber
  • Size (String)

Implement the class Pants. This class implements Clothing. Additionally it has these properties:

  • Suitability : only valid values are : male, female, unisex
  • Size : If Suitability male or unisex, only valid values are numbers 44 to 56 If Suitability is female, only valid values are numbers from 32 to 46

Implement the class Top. this class will implement Clothing.

  • Size: only valid values are: XXS, XS, S, M, L, XL, XXL, XXXL

Implement the class Dress. This class implements Clothing. It has additional properties:

  • Size: only valid values are numbers 32 to 46

All attributes of the classes Pants, Top and Dress must be determined in the constructor.

Make sure, the Output of an Object of type Garderobe with System.out.println

--> System.out.println(Garderobe)

will output this description of the Garderobe:

# Garderobe < Name> of < Owner>, Total Capacity:
< Capacity>, Numbers of free capacity in the Garderobe:
< Capacity minus Number of clothes in this Garderobe>, Content:
# < per line: Call of the toString methods of all clothing pieces in this Garderobe>

Make sure, that the output of an object, which implements Clothing outputs the typ of its class and all attributes. Example:

# Pants: Joggingpants, Blue, Hervis, PUM4-123, unisex, 44

Important: in a list of Clothing in a Garderobe there MUST NOT be two same objects. two objects are the same, if the combination of Shop and ItemNumber is the same.

Function and Exceptions:

  • When attempting to add new Clothing with the method add(Clothing k) to the Garderobe, it should be first checked with method search (Clothing k) if this Clothing already exists in the Garderobe. if it exists, a DuplicateClothException should be thrown which contains a appropriate message.
  • The Garderobe should have a method hasFreeRoom() which returns a boolean true if there is still room in the Garderobe, otherwise false. call this method before new Clothing is added to the Garderobe.
  • when attempting to add more Clothes to the Garderobe than the capacity allows, a WardrobeOutOfBoundException should be thrown, which contains a appropriate message.
  • when attempting to add a invalid size (see requirements above for each class) a InvalidClothSizeException should be thrown which contains a appropriate message.
  • when attempting to give a String to the variable Size, which does not contain a whole number (integer), a NumberFormatException should be thrown in the classes Dress and Pants.

Implement the Exception types given above: DuplicateClothException, WardrobeOutOfBoundException, (must be derived from IndexOutOfBoundsException) InvalidClothSizeException

Dont forget to use dynamic binding and final whenever possible.

Questions: - what advantage does dynamic binding offer in this program?

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.