Hey guys im completely new to programming and im complete stuck and any help to comlete my assingment would be greatly appreciated. heres my assingment.
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 buy. Implement these properties within your hierarchy as appropriate.