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

java question! public class Baker {public void doThings (Recipe r) {String instr

ID: 3576227 • Letter: J

Question

java question!

public class Baker {public void doThings (Recipe r) {String instruction = readNext(r); System. out. print f (" Ah, now I must %s%n", instruction); r = r. getTail (); if (r != null) {//TODO: Carry out the instruction doThings (r);}} public String readNext (Recipe r){String ret = r.getHead(); if (ret = null) {return "sit back and relax";} r = r. getTail (); return ret;}} And if you have the following code in your " main" method: Recipe r = new Recipe (); r. setHead (" Preheat oven to 350 degrees"); r. setTail (new Recipe (" Combine dry ingredients in a bowl")); r. append (new Recipe (''Combine wet ingredients in a separate bowl and mix until smooth", new Recipe (" Combine wet and dry ingredients", new Recipe (" Bake")))); Create an interface that would cover all of the Recipe class' methods. Call it Recipelnterface. How many constructors does Recipe need? Write the code for each.

Explanation / Answer

A. Interface Declaration RecipeInterface:

public interface RecipeInterface {

public void setHead (String head);

public void setTail(Recipe recipe);

public void append(Recipe recipe1, Recipe recipe2);

}

Number of constructors required is 3 (one non-parametrized constructor and two parametrized constructors).

1. public Recipe () {

}

2. public Recipe (String recipe) {

// Do To List

}

3. public Recipe (Recipe recipe1, Recipe recipe2) {

// Do To List

}