Answer to Question #121791 in Java | JSP | JSF for Syeda Aimen Azeem

Question #121791
The following class Pizza has incomplete codes. Write setter and getter methods for all instance variable of the class, create a parameterized constructor of this class, use isLargePizza() method, and toString() method.


public class Pizza {

String name;
double diameter;

//constructor
void Pizza()
{
//Missing Lines
}

public String isLargePizza()
{
// missing lines
}

@Override
public String toString() {
// missing lines
return super.toString();
}


Hint: When the size of the pizza is greater than 20cm, then it must be considered as large pizza. The islargePizza() method must return boolean value indicating whether the pizza is large or not.
Also, correct the given code where necessary.
1
Expert's answer
2020-06-12T07:40:05-0400

public class Pizza {


String name;

double diameter;


public Pizza(String name, double diameter) {

this.name = name;

this.diameter = diameter;

}


public boolean isLargePizza() {

return diameter > 20;

}


public String getName() {

return name;

}


public void setName(String name) {

this.name = name;

}


public double getDiameter() {

return diameter;

}


public void setDiameter(double diameter) {

this.diameter = diameter;

}


@Override

public String toString() {

return super.toString();

}

}


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