Your task for this assignment is to define multiple classes


Your task for this assignment is to define multiple classes via inheritance. Your classes should implement various "snacks" including "M&Ms", "Popcorn", etc.

To begin, create an abstract "Snack" class. Then, create two classes "Salty" and "Sugary" that inherit from the "Snack" class. Then create classes "M&Ms", "Popcorn", "Snickers", "Gum", "Crackers", and "Chips" that inherit from "Salty" or "Sugary" as appropriate.

Once you have your inheritance hierarchy defined, implement the toString method for each class.

Finally, let''s presume that each snack has two additional properties: "calories" and "cost". Calories is an integer that represents how many calories the snack contains, and cost is a floating-point number that represents how much the snack costs to bu y. Implement these properties within your hierarchy as appropriate.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Your task for this assignment is to define multiple classes
Reference No:- TGS01159587

Expected delivery within 24 Hours