Question: Please help me with the following Java programming project task, I hope to get a correct answer as a reference, thank you very much. I

Please help me with the following Java programming project task, I hope to get a correct answer as a reference, thank you very much.
I need to complete the DimSum class for storing the information of the dim sum dishes,such as
Barbecued pork bun $25.0
Shrimp dumpling $38.0
Siu mai $30.0
Spring roll $25.0
For example, if you want to create the dim sum 'Siu Mai' you will use the following code:
DimSum siumai = new DimSum("Siu Mai", 30f);
The above example creates an instance of the DimSum class and the dimsum object stores the name as "Siu Mai" and its price as 30. For the class, you need to store the input parameters name and price to the name attribute and the price attribute. You may find that you need to use this.name and this.price when you assign the values to the attributes, for example like this:
this.name =...;
this.price =...;
After that you also need to initialize the quantity attribute to become 0.
Here's the unfinished part of the code, please help me build on it to complete it.
public class DimSum
{
//
// Task 1- create the attributes
//
// The name of the dim sum
// The price of the dim sum
// The quantity ordered
// Constructor of the class
public DimSum(String name, float price){
//
// Task 1- Initialize the attributes of the dim sum
//
}
// Return the name of the dim sum
public String getName(){
//
// Task 1- Return the name of the dim sum
//
return "DimSum";
}
// Return the price of the dim sum
public float getPrice(){
//
// Task 1- Return the price of the dim sum
//
return 0f;
}
// Return the quantity ordered
public int getQuantity(){
//
// Task 1- Return the quantity of the dim sum
//
return 0;
}
0
ds// Order this dim sum dish
public void order(int quantity){
//
// Task 1- Increase the quantity ordered
//
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!