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:
Every attribute except the list of clothes must be determined in the constructor. These must be private.
Implement the Interface Clothing with these attributes:
Implement the class Pants. This class implements Clothing. Additionally it has these properties:
Implement the class Top. this class will implement Clothing.
Implement the class Dress. This class implements Clothing. It has additional properties:
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:
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?