Escolar Documentos
Profissional Documentos
Cultura Documentos
Tip Top Bakery wants a program to build a sandwich and provide them the
number of calories for a combination of bread and filling.
Create a field to hold the name of the sandwich and its price. Create get and
set methods for both fields.
Create a field to hold a Bread object. When creating the field, declare and
then initialize it by creating a new Bread object. Create get and set methods.
Create a field to hold a Filling object. When creating the field, declare and
then initialize it by creating a new Filling object. Create get and set
methods.
Create a constructor that accepts the name, price, bread attributes, and
filling attributes of the Sandwich object and sets them all in the object.
Create a method that returns the total number of calories of the sandwich.
Assume that a Sandwich has two slices of Bread and one serving of Filling.
Ask the user for all the attributes of a Sandwich needed for the constructor
(see Sample Output section below)
Create a Sandwich object, passing all of the data obtained from the user into
the object via its constructor.
Sample Output
----jGRASP exec: java SandwichBuilder
What is the name of the sandwich? HappyBrat
What is the price? 4.99
What type of bread? white
How many calories per slice? 300
What kind of filling: jelly
How many calories per serving? 250
The HappyBrat comes on two slices of white
bread with jelly for $4.99 (660 calories)
----jGRASP: operation complete.