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

Can someone help me with this part please, write up the code so I can compare it

ID: 665044 • Letter: C

Question

Can someone help me with this part please, write up the code so I can compare it to my own code.

---------

To begin, add a Bread class to the .java file that contains the items indicated in the UML diagram shown below:

---------------

UML class diagrams are divided into three sections. The first section contains the name of the class. The second section lists all the fields contained within the class. Each field has a name and a data type. The name is displayed first, then the colon, and then the data type. The third section contains all of the methods of the class. For a given method, the name comes first followed by a set of parenthesis where arguments may or may not be passed to the method. Methods that require arguments show them with the data type first, a space, and then the name of the parameter. After the closing parenthesis and colon, the return data type of the method is displayed. All methods with the exception of constructors (which never have return types) have this notation. Methods that do not return values use the void data type. A minus sign (-) indicates that the item is private, whereas a plus sign (+) indicates it is public. You will notice that in all of the classes in this course, the fields are always private and the methods are usually public. I say usually because every once and a while you may want to create a helper method that you don't expose to the outside world but that other methods within the same class can use. Methods like this are usually referred to as helper methods.

--------------

To build the Bread class, add the fields and methods to the class as shown in the diagram.The constructor for this class should accept the filling type and calories per serving. Then, within the body of the method, call the setter methods to store them.

This is my code, and it's not really working:

public class Bread
   {
       private String breadType;
       private int breadCalories;
    public Bread(String type, int calories)
           {
               this.breadType = type;
               this.breadCalories = calories;
           }
       public String getBreadType()
           {
               return breadType;
           }
       public int getBreadCalories()
           {
               return breadCalories;
           }
   }

Explanation / Answer

Hint:Main method of your code

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;

           }

   }

public class bread

            {

          Public static void main(string args[])

              {

                   int breadty,cal,top,calc;

                   Bread b=new Bread();object //object created for bread class

                   Sandwich s=new Sandwich();////object created for sandwich class

                   SandwichFilling sf=newSandwichFilling();//object creation for sandwich filling

                   Scanner in=new scanner(System.in);//input from the programmer

                   breadty=in.nextInt();

                   b.getBreadType();

                   System.out.println("How many calories:");

                   cal=in.nextInt();

                   b.getBreadCalories();

                   System.out.println("choose your toppings:");

                   top=in.nextInt();

                   s=getTypeFilling();

                   calc=s.getFillingcalories()

                   System.out.println("This sandwich has two silcesof "+breadty);

                   System.out.println("calories"+cal");

                   System.out.println("with filling"+top);

                   System.out.println("The total number of calories for the sandwich is"+calc:");

                   sf.getTypeFilling();

                   sf.getFillingCalories();

              }

          }