Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class for Tip Top Bakery named bread with data fields for bread type (s

ID: 3666530 • Letter: C

Question

Create a class for Tip Top Bakery named bread with data fields for bread type (such as "rye") and claories per slice. Include a constructor that takes parameters for each field, and include get methods that returns the values of the fields. Also included a public final static String named MOTTO and initialize it to The staff of life. Write an application named TestBread to instatiate 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.

Explanation / Answer

}

public class Bread { private String breadType; private int breadCalories; public final static String MOTTO = "The Staff Of Life"; public Bread(String type, int calories) { this.breadType = type; this.breadCalories = calories; } public String getBreadType() { return breadType; } public int getBreadCalories() { return breadCalories; }

}

package Tip_Top_Bakery; /** * Project: Java Programming * Package: Tip_Top_Bakery * File: TestBread * Created by Kimberly Henry <kimbelry.henry@outlook.com> * On 18-Jun-2014 * At: 7:05 PM */ public class TestBread { public static void main(String[] args) { Bread test001 = new Bread("Wheat", 69); Bread test002 = new Bread("White", 494); Bread test003 = new Bread("Sourdough", 96); System.out.println(Bread.MOTTO); System.out.println("Bread test001 Bread Type: " + test001.getBreadType()); System.out.println("Bread test001 Bread Calories: " + test001.getBreadCalories()); System.out.println(); System.out.println(Bread.MOTTO); System.out.println("Bread test002 Bread Type: " + test002.getBreadType()); System.out.println("Bread test002 Bread Calories: " + test002.getBreadCalories()); System.out.println(); System.out.println(Bread.MOTTO); System.out.println("Bread test003 Bread Type: " + test003.getBreadType()); System.out.println("Bread test003 Bread Calories: " + test003.getBreadCalories()); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote