Question: Here is a java file that I need your help to check if it can function properly. If there is a problem, please let me
Here is a java file that I need your help to check if it can function properly.
If there is a problem, please let me know how to change it if there is no problem, please let me know, thank you.
File :
public class DimSum
Task : Create the attributes
private String name; The name of the dim sum
private float price; The price of the dim sum
private int quantity; The quantity ordered
Constructor of the class
public DimSumString name, float price
Task : Initialize the attributes of the dim sum
this.name name;
this.price price;
this.quantity ; Initialize quantity to
Return the name of the dim sum
public String getName
Task : Return the name of the dim sum
return this.name;
Return the price of the dim sum
public float getPrice
Task : Return the price of the dim sum
return this.price;
Return the quantity ordered
public int getQuantity
Task : Return the quantity of the dim sum
return this.quantity;
Order this dim sum dish
public void orderint quantity
Task : Increase the quantity ordered
this.quantity quantity;
public static void mainString args
Example usage
DimSum siumai new DimSumSiu Mai", f;
System.out.printlnName: siumai.getName;
System.out.printlnPrice: siumai.getPrice;
System.out.printlnQuantity: siumai.getQuantity;
siumai.order; Order Siu Mai
System.out.printlnUpdated Quantity: siumai.getQuantity;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
