Java OOP GUIDE / WORK FOOD SUPERCLASS 2 Topics
TASK –
PART 1 – SETUP – FOOD CLASS To start, you
need the Food class from the first part of this work. You can either go do that work or go get it
from the Solutions. TASK –
PART 2 – SANDWHICH CLASS We
will create the Sandwhich class with the following
specifications: ·
It
will extend the Food class. ·
It
has the following instance variables (all of type String): o breadType, o toppings, and o spreads ·
It
has a constructor that gets a value for all 7 instance variables. Remember that three of the instance
variables are inherited from Food. ·
It
has a toString() method that returns something similar to:
|
TASK –
PART 3 – SANDWHICH TESTER Place
at least two Food elements and two Sandwhich
elements into the array. Loop
over the lunch array to display its content. Note:
The toString method in the Food class should maybe
be improved to include the name of the food and its flavour. |