Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA Create a class named Order that stores information about purchases in a store. The details of the class are listed below. Please note

IN JAVA

Create a class named Order that stores information about purchases in a store. The details of the class are listed below. Please note the the description instance variable should be no larger than 80 characters.

NOTES: Skip methods that are not mentioned here. Only write the instance variables, constructors and methods asked below, any additional code will not be graded. Import statements or comments are not required.

a) Instance variables (all private except constant) i) TAXRATE a double typed constant that stores the current tax rate. Initialize this value to 0.075. ii) id an int representing the store internal ID number of the item. iii) description a String describing the item. Must be no more than 80 characters. iv) quantity an int representing the number of items purchased. v) price a double representing the cost of each item before taxes.

b) Constructors i) Default constructors that sets all instance variables to default values (0 for numeric variables and empty string for strings). You may also choose to call the parameterized constructor; ii) A parameterized constructor that sets the instance variables to the parameters. So there will be four parameters corresponding to four instance variables. Call mutator to set the value of instance variables rather than assignment if you want validation to be applied.

c) Methods (all public) i) Accessor method for id, quantity and price; ii) Mutator method for id, quantity and price; iii) Mutator method for description. - If the deception is greater than 80 characters, display an error message "Description too long!" and set the description instance variable to the first 80 characters; iv) totalCost a method that returns a double value representing the total cost of the order. Total cost includes the quantity purchased and the tax. So the formula will be quantity * price * (1 + TAXRATE).

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

More Books

Students also viewed these Databases questions

Question

=+ What is the role of government in bargaining?

Answered: 1 week ago

Question

=+ Who is the negotiation partner at company level?

Answered: 1 week ago