Answer to Question #115943 in Java | JSP | JSF for natanael

Question #115943
a) Create a class named Sandwich. Data fields for this class include a String for the main ingredient (E.g. Tuna), a String for bread type (E.g. Wheat) and the third field for double data type to store the sandwich price (N$15.00). Include methods to get and set values for each of these fields. Save the class as Sandwich.java.
1
Expert's answer
2020-05-15T09:47:08-0400
public class Sandwich {
    private String mainIngredient;
    private String breadType;
    private double price;
    
    public String getMainIngredient() {
        return mainIngredient;
    }

    public void setMainIngredient(String mainIngredient) {
        this.mainIngredient = mainIngredient;
    }

    public String getBreadType() {
        return breadType;
    }

    public void setBreadType(String breadType) {
        this.breadType = breadType;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS