For as long as you can remember, you've never been able to get a taco on Tuesday at your local taco truck. The lines are always too long and the staff are very overwhelmed. You take it upon yourself to streamline the taco ordering process to decrease the average time it takes to get a taco. You decide to create a process that will take customer orders and print them out in a neat and understandable format. To increase the efficiency of your code, you're going to use the `Taco.java` class for every taco. You're going to write the process of creating a taco object from an order in `PoD.java`.Taco-shell: boolean -toGo: boolean -ingredients: String +Taco () +getShell(): boolean +get ToGo (): boolean +get.Ingredients: String +set Shell (shell: boolean) +set ToGo (togo: boolean) +setIngredients (ingredients: String) +toString(): StringOnce you've created a Taco object, the object will be printed by making use of the 'toString()' method. Details (POD.java) Input The main method of PoD.java reads in input in the following order (handled for you): • a boolean (shell): the shell type (true if hard shell, false if soft shell) • a boolean (to Go): if the order is to eat in or out • a list of ingredients (ingredients): an array of strings describing which ingredients are in the taco. The 'Taco.java' class accepts a single String. Processing WHAT YOU MUST DO: Create a Taco object Assign input to Taco object Print out Taco object Output Output is already done for you by making use of the 'toString()' method in the 'Taco.java' object class. Sample input/output: Sample Input Sample Output Note: This is all on a single line! false true lettuce tomato cheese Shell: soft Order: to go Ingredients: lettuce tomato cheese

Answer :

Answer:

import java.util.Scanner;

/*

* Class Taco

* @shell

* @togo

* @ingredients

*/

class Taco{

//Attributes

private boolean shell;

private boolean togo;

private String ingredients;

//Default constructor

public Taco() {

shell=false;

togo=false;

ingredients="";

}

//Parameterized constructor

public Taco(boolean shell,boolean togo,String ingredients) {

this.shell=shell;

this.togo=togo;

this.ingredients=ingredients;

}

//Getters and setters

public boolean isShell() {

return shell;

}

public void setShell(boolean shell) {

this.shell = shell;

}

public boolean isTogo() {

return togo;

}

public void setTogo(boolean togo) {

this.togo = togo;

}

public String getIngredients() {

return ingredients;

}

public void setIngredients(String ingredients) {

this.ingredients = ingredients;

}

//override to string

public String toString() {

String str="Shell: ";

if(shell==false) {

str+="soft\n";

}

else {

str+="hard\n";

}

str+="Order: ";

if(togo==false) {

str+="out\n";

}

else {

str+="togo\n";

}

str+="Ingredients: "+ingredients;

return str;

}

}

public class PoD {

public static void main(String[] args) {

//Scanner object for input read

Scanner sc=new Scanner(System.in);

//user inputs

System.out.print("Do you want taco shell hard or soft(true/false): ");

boolean shell=sc.nextBoolean();

System.out.print("Do you want taco in and out(true/false): ");

boolean togo=sc.nextBoolean();

sc.nextLine();

System.out.print("Enter all ingredients: ");

String ingredients=sc.nextLine();

//Create Taco object

Taco taco=new Taco(shell,togo,ingredients);

System.out.println("\n"+taco+"\n");

System.out.println("END OF OUTPUT");

}

}

Other Questions