Question
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
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.
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): StrinStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started