// function to order a cake, accepts topping order list, size and quantity values public void orderCake(String[] topping
Posted: Thu Jun 02, 2022 8:13 am
// function to order a cake, accepts topping order list, size and quantity values public void orderCake(String[] toppingOrder, int quantity, int size) { this.toppingOrder = toppingOrder.clone(); this.size = size; this.quantity = quantity; } // function to return price according to size of cake public double getSizePrice() { if (size== 1) return priceSmall; else if (size==2) return priceMedium; else return priceBig; } // function to return total price public double getTotalPrice() { } // function to return a string representation of size public String getSize() { if(size == 1) return "Small"; else if(size == 2) return "Medium"; else return "Big"; } totalPrice=(getSizePrice()* quantity+(toppingOrder.length*10)); return totalPrice;
BY USING JAVA: 1. Create the GUI application for Cake Order. 2. Save (add) order into a text file. 3. Implement an exception handling. Can you please make a Gui based on the class that I gave. But make sure the class is still there just make a gui for the given classes and save it to a text file and also implement an exception handling into the code. You may add any other function to it. Thank you in advance. I will sure to give you thumbs up. public class Cake{ // declaring required variables private String name; private String[] topping; private String[] toppingOrder; private double priceSmall; private double priceMedium; private double priceBig; private double totalPrice; private int size; private int quantity; // parameterized constructor public Cake(String name) { this.name=name; } // function to set topping list and different price values public void setCake(String[] topping, double priceSmall, double this.topping = topping.clone(); this.priceSmall = priceSmall; this.priceMedium = priceMedium; this.priceBig = priceBig; priceMedium,double priceBig) { }