Create a class named MELTING SPOT that stores information about single pizza. It should contain the following: • Private variables to store the size of pizza (“small”, “medium” or “large”), the number of cheese topping and number of pepperoni toppings and the name of the shop. • Public method to set the data for pizza like size, and number of cheese and pepperoni toppings. • Public method named calculate Cost() that calculates the cost of pizza. • Pizza cost is determined by: Small: 10 $ + 2$ per topping Medium: 12$ +4$ per topping Large: 14$+ 6$ per topping Create 3 – 4 pizza objects and display their final cost and the name of name of the shop. For example, a small pizza with 2 cheese toppings and 3 pepperoni toppings at melting spot costs around 20$.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create a class named MELTING SPOT that stores information about single pizza. It
should contain the following:
• Private variables to store the size of pizza (“small”, “medium” or “large”), the
number of cheese topping and number of pepperoni toppings and the name of
the shop.
• Public method to set the data for pizza like size, and number of cheese and
pepperoni toppings.
• Public method named calculate Cost() that calculates the cost of pizza.
• Pizza cost is determined by:
Small: 10 $ + 2$ per topping
Medium: 12$ +4$ per topping
Large: 14$+ 6$ per topping
Create 3 – 4 pizza objects and display their final cost and the name of name of
the shop. For example, a small pizza with 2 cheese toppings and 3 pepperoni
toppings at melting spot costs around 20$.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images