Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA . 1. Create a Project called PizzaShop 2. In the PizzaShop project, create a class called Pizza with variables of: size (String) - small,

JAVA .

1. Create a Project called PizzaShop 2. In the PizzaShop project, create a class called Pizza with variables of:

  • size (String) - small, large
  • crust (String) - thin, hand-tossed, pan
  • topping (String) - e.g., pepperoni, sausage, hamburger, bacon, veggie - they will only get to choose one to keep it simple
  • extras (int) - number of extras such as extra cheese, another meat or veggie, etc. - this will just keep track of the NUMBER of other toppings, we won't worry about what they actually are.
  • price (double)

3. Create a constructor for the Pizza class. It should initialize

size="" crust="" topping="" extras=0 price=0

It does not have any parameters.

4. Create get/set methods for the size, crust, topping, and extras variables. We will only keep track of the total number of extras and assume they all cost the same.

5. For the price variable, you don't need to create get or set methods, but create a method called calcPrice(). It should assign and return the price variable for a Pizza object. In calcPrice(), set the price to $8 for small and $10 for large. Thin and hand-tossed don't cost extra, but pan costs $2 extra. Add $1 for each extra.

6. In main(), create an object myPizza of type Pizza. Ask the user what size of pizza, the type of crust, the topping, and the number of extras they want. Using your set methods, set the values the user enters for the myPizza object's variables.

Call the get methods for each of the object's variables to display their values. Then call the calcPrice() method for myPizza to calculate and print the price. Print the price with a $ and two decimal places.

7. Modify the Pizza class to include a totPizzas variable. This should be a static variable of type int and initialized to 0. It will keep track of the total number of Pizza objects created (i.e., total pizzas sold). Whenever the constructor for Pizza is called, update totPizzas by 1.

Create a get method (static) that returns totPizzas.

In main, call getTotPizzas() and print how many pizzas were ordered - at this point, it should just be 1.

Also Add a while loop to allow the user to buy more pizzas or exit. After the loop has exited, print totPizzas (the total number of pizzas sold). NB: In order for totPizzas to be updated, the call to the constructor will need to be inside the loop.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

Identify the different methods employed in the selection process.

Answered: 1 week ago

Question

Demonstrate the difference between ability and personality tests.

Answered: 1 week ago