Question: JAVA Extend the Shop Class you wrote yesterday and implement the ShoeShop class (see the UML diagram). Details Shop Class: The constructor in the Shop
JAVA
Extend the Shop Class you wrote yesterday and implement the ShoeShop class (see the UML diagram).
Details
Shop Class: The constructor in the Shop class sets name and initializes the revenue to 0. The Shop toString method returns the name of the restaurant and the revenue.
ShoeShop Class The constructor sets the name of the ShoeShop, price for a pair of shoes and sets sales to 0 sale ( ) method is called every time a pair of shoes are sold. It increases the sales by num, it calculates the revenue of the sale based on the number of sales and price of the shoes. It updates revenue. The toString method builds on the supers toString method by adding the number of sales and price of a pair of shoes (see output) Both toString methods should print to 2 decimal places
To control the format for decimals in the toString method, you can use the DecimalFormat class (import java.text.DecimalFormat)
Here is an example of how it works:
public String toString() { //assume you are print some calculation value [value] that has several decimal places and you //want it to print only 2 decimal places DecimalFormat df = new DecimalFormat("#.00"); //give it the format return "Value is : " + df.format(value); //changes double value to have 2 decimal places } Write a demo program, that will use a Scanner to read the attributes to create two ShoeShop objects (name and price), and then two integers representing the pairs of shoes ordered for both shops (pass these numbers into sales). Then print both ShoeShop objects.
Input
Example Input: EmmaShoes 32.99 BrownBoots 21.99 10 12
Output
Example Output: EmmaShoes Revenue: 329.90(Totalsold:10.00at329.90(Totalsold:10.00at32.99) BrownBoots Revenue: 263.88(Totalsold:12.00at263.88(Totalsold:12.00at21.99)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
