Question
Design an inheritance hierarchy using UML. (1) Product class, (2) Drink class and Snack class (sub-class of Product) (3) Candy class, Chips class and Gum
Design an inheritance hierarchy using UML. (1) Product class, (2) Drink class and Snack class (sub-class of Product) (3) Candy class, Chips class and Gum class (sub-classes of Snack). Make sure that all classes include the following: 1. No argument constructor 2. Overloaded constructor that initializes the fields with the parameters 3. Overloaded copy constructor that initializes the fields with a copy of another object's fields 4. A toString() method Implementing the classes, use your UML to write the code to implement the following classes: (1) Product (make this class abstract) (2) Snack (make this class abstract) 3. Drink 4. Candy 5. Chips 6. Gum 7. Dispenser (add a constructor that populates the Dispenser class array with a variety of Products) 8. Finally, write a main method that creates a Dispenser and calls the Dispenser method displayProducts(). Submit your files, which includes the main() method and all classes.
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