Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions