classBurrito { private int beans; private int beef; private int cheese; private
ID: 3614542 • Letter: C
Question
classBurrito
{
private int beans;
private int beef;
private int cheese;
private int salsa;
// a special "method" - aClass CONSTRUCTOR!!!
public Burrito() // method header
{
System.out.println("making a BLT with DEFAULT ingredients");
beans =2;
beef =1;
cheese = 1;
salsa =1;
}
// a special "method" - aClass CONSTRUCTOR!!!
public Burrito(int b, int f, int c, int s) // method header
{
System.out.println("making a Burrito with CUSTOM ingredients");
beans =2;
beef =l;
cheese = 1;
salsa =1;
}
public void print_order()
{
System.out.println("beans = " + beans);
System.out.println("beef= " + beef);
System.out.println("cheese = " + cheese);
System.out.println("salsa = " + salsa);
}
public int weight()
{
int sum;
sum =beans + beef + cheese + salsa;
returnsum;
}
}
public classLab6
{
public static void main(String args[])
{
Burrito Burrito1 = newBurrito();
Burrito Burrito2 = newBurrito(8,2,3,1);
System.out.println("Burrito:");
Burrito1.print_order();
System.out.println("weight of Burrito = " +Burrito1.weight());
System.out.println("custom Burrito:");
Burrito2.print_order();
System.out.println("weight of Burrito @ = " +Burrito2.weight());
}
}
Explanation / Answer
making a BLT with DEFAULTingredients
making a Burrito with CUSTOMingredients
Burrito:
beans = 2
beef = 1
cheese = 1
salsa = 1
weight of Burrito = 5
custom Burrito:
beans = 2
beef = 1
cheese = 1
salsa = 1
weight of Burrito @ = 5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.