The purpose of this exercise is to give you more practice with object oriented design -- combining objects, and understanding when and how to use inheritance in java. The idea will be to create a large number of different classes, and mix them together in various ways.
The main goal is to create and use objects representing the various components of a salad.
Create a class of type Salad. It must be made up of ingredients which are implemented as objects of other classes. These should not be subclasses of Salad -- they are components of Salad.
One of the main kinds of ingredients to work with are vegetables. Create a class of type Vegetable. Give it several properties such as color, crunchiness, price, etc. Use your imagination.
Create subclasses of type Vegetable such as Carrot, Lettuce, Celery, etc. Be sure to add or override at least one instance variable, or override at least one method from the superclass whenever it makes sense to do so. For example, consider a method like washIngredient() You would make the default method reside in Vegetable, and let subclasses redefine where to look. E.g., washIngredient() might use water for lettuce but a brush for mushrooms.
Create subclasses for at least one of the Vegetable subclasses. For example, you might make IcebergLettuce and RomaineLettuce subclasses of Lettuce. Again, be sure to add or override instance variables, or override methods from the superclass. (This could include changing the default values for certain instance variables.)
For the Salad class, you'll need to write methods to do things to create objects of type Salad. You may want to have methods like addIngredient() and tossSalad() and dressSalad(Dressing d) and so on. You may want to allow parameters such as to control how many people the salad needs to feed and how much the salad can be allowed to cost.
Make subclasses of the Salad class. For example, make CaesarSalad, SpinachSalad, and MixedBabygreenSalad subclasses. Each of these will have different ingredients and different preparation types. Try to use subclassing and method overriding effectively to get a clean design.
The output could be a description of the salad, a calorie count, a cholesterol count, a price, etc. (e.g., adding in artichokes increases the price).
Today we will