-------------------------------------------------
Program Plan: * Create a class Pizza * Define the variables * Provide methods to get and set these variables
-------------------------------------------------
/*********************************************************************** The program Pizza.java creates a class Pizza and defines methods to get and set variables in the class
***********************************************************************/
Program:
//creating class Pizza class Pizza
{
//declaring the fields in the class String Toppings; int Diameter; double Price;
-------------------------------------------------
//defining methods to set and get the field Toppings respectively void setToppings(String z) { //setting the filed Toppings Toppings=z; }
String getToppings() { return Toppings; }
-------------------------------------------------
//defining methods to set and get the field Diameter respectively void setDiameter(int x) { //setting the filed Diameter Diameter=x; }
int getDiameter() { return Diameter; }
-------------------------------------------------
//defining methods to set and get the field Price respectively void setPrice(double y) { //setting the field Price Price=y; }
double getPrice() { return Price; }
}
-------------------------------------------------
Program Plan: * Create a class Pizza * Define the variables * Provide methods to get and set these variables * Create another class TestPizza * Initialize an instance of the class Pizza * Set the fields of the instance with a value * Output those fields with the use of getter functions