Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Help PizzaShop Class When declaring the static variables totalShops set it to 0 and set totalSales to 0.0 The constructor updates the static variable

Please Help

image text in transcribed

PizzaShop Class

When declaring the static variables totalShops set it to 0 and set totalSales to 0.0

The constructor updates the static variable totalShops by one, it sets the name of the pizzaShop to Shop+totalShops (for example, if this is the 3rd shop created it would be Shop3), sets the price for a pizza from the passed in value, and sets numSale to 0

Add get/set methods for totalSales

sale ( ) method is called every time a pizza/s are ordered/sold. It increases the numSale by num, it calculates the revenue of the sale based on the numSale and price of the pizza. It updates the static variable totalSales to include this sale.

totalLocalSales calculates and returns the total sales for this pizza shop (numSales*price)

The static method aveSalesPerShops returns the average sales for each shop (totalsales/total num) using the class name PizzaShop (see output).

The toString method prints the pizza shop name and total sales for this shop (e.g., numSale * price) (see output)

The toString method should print to 2 decimal places. Recall to control for decimals in the toString method you can use the DecimalFormat class (you need to import the class - import java.text.DecimalFormat). Here is an example of how it works:

Write a demo program, that will use a Scanner to read the attributes to create four PizzaShops objects (pizza price), and then four integers representing the pizzas ordered for all four shops (pass these numbers into sale). Then call the toString for all pizzashops. Finally using the class name print the number of all PizzaShops, the total revenue (totalSales), and call/print the results aveSalesPerShop. Make sure you print out to two decimal places.

image text in transcribed

PizzaSho -price : double//price per one pizza -numSale: int /umber of pizzas ordered static totalSales : double//keeps track of all pizzaShop sales set to 0.0 - static totalShops: int //update every time a new pizzashop is created //set to 0 + PizzaShop (price: double) +getPrice ) double + getNumSale nt + static getTotalShops (): int + static getTotalSales (): double +static setTotalSales(s: double): void +getName ) String +setPrice (p double): void +setNumSale (num: int): void +sale (num : int) : double +totalLocalSales() : double + static aveSalesPerShops(): double +toString): Strin

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

Step: 3

blur-text-image

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

5. Recognize your ability to repair and let go of painful conflict

Answered: 1 week ago