Constructor Based Programs
Constructor Based Programs
Instance Variables:
String pizzaSize — to store the size of the pizza (small, medium, or large)
int cheese — the number of cheese toppings
int pepperoni — the number of pepperoni toppings
int mushroom — the number of mushroom toppings
Member Methods:
Constructor — to initialise all the instance variables
CalculateCost() — A public method that returns a double value, that is, the cost of the pizza.
Pizza cost is calculated as follows:
PizzaDescription() — A public method that returns a String containing the pizza size, quantity of each
topping, and the pizza cost as calculated by CalculateCost()
Data members:
Member methods
Electricity (name,cno,unit)
Write a main method to create object of a class & call the above member method