Question: 5. a. Create a class for the Tip Top Bakery named Bread with data fields for bread type (such as rye) and calories per slice.



5. a. Create a class for the Tip Top Bakery named Bread with data fields for bread type (such as rye) and calories per slice. Include a constructor that takes parameters for each field, and include get methods that return the values of the fields. Also include a public final static String named MOTTO and initialize it to The staff of life. Write an application named TestBread to instantiate three Bread objects with different values, and then display all the data, including the motto, for each object. Save both the Bread.java and TestBread.java files. b. Create a class named SandwichFilling. Include a field for the filling type (such as "egg salad") and another for the calories in a serving. Include a constructor that takes parameters for each field, and include get methods that return the values of the fields. Write an application named Test SandwichFilling to instantiate three SandwichFilling objects with different values, and then display all the data for each object. Save both the SandwichFilling.java and TestSandwichFilling.java files. c. Create a class named Sandwich. Include a Bread field and a SandwichFilling field. Include a constructor that takes parameters for each field needed in the two objects and assigns them to each object's constructor. Write an application named TestSandwich to instantiate three Sandwich objects with different values, and then display all the data for each object, including the total calories in a Sandwich, assuming that each Sandwich is made using two slices of Bread. Save both the Sandwich.java and Test Sandwich.java files. x C. Command Prompt D:\JavaBatchFile>javac Bread.java D:\JavaBatchFile>. 5b: 04. Command Prompt D:\JavaBatchFile>javac SandwichFilling -java D:\JavaBatchFile). TII 5e: GX Command Prompt c. Con D:\JavaBatchFile>javac Sandwich.java D:\JavaBatchFile> D:\Jak D:\Ja D:\Jau The pl The The The nu The x Command Prompt D:\JavaBatchFile>java Test Bread The rye bread has 120 calories per slice The bread motto is The staff of life The wheat bread has 95 calories per slice The bread motto is The staff of life The white bread has 100 calories per slice The bread motto is The staff of life D:\JavaBatchFile>. TI 01. Command Prompt g-java D:\JavaBatchFile>javac SandwichFilling -java D:\JavaBatchFile>javac TestSandwichFilling.java D:\JavaBatchFile>java Test SandwichFilling The egg salad filling has 220 calories The ham filling has 240 calories The peanut butter filling has 280 calories D:\JavaBatchFile> G Command Prompt D:\JavaBatchFile>javac Sandwich.java D:\JavaBatchFile>javac TestSandwich.java D:\JavaBatchFile>java Test Sandwich The pumpernickel bread has 180 calories per slice The egg salad filling has 220 calories The sandwich, with 2 two slices of bread, has 580 calories The nult igrain bread has 200 calories per slice The bologna filling has 260 calories The sandwich, with 2 two slices of bread, has 660 calories The whole wheat bread has 150 calories per slice The grape jelly filling has 180 calories The sandwich, with 2 two slices of bread, has 480 calories D:\JavaBatchFile>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
