Answered step by step
Verified Expert Solution
Question
1 Approved Answer
GroceryItemOrder Class: Name your class as: GroceryItemOrder . java You are to design a class GroceryItemOrder which represents an item to be included in the
GroceryItemOrder Class:
Name your class as: GroceryItemOrderjava
You are to design a class GroceryItemOrder which represents an item to be included in the
list.
Fields of course, all fields are private:
A string named name to store the name of the item in the list.
An integer named quantity to store the quantity of the item to be purchased.
A double named pricePerUnit to store the price of each item in the list.
Constructor:
Takes three parameters as the users input for the name of the item, quantity of the item
and price of each item.
The constructor initializes the name, quantity, pricePerUnit fields in the class using the
constructor arguments.
Methods be certain to declare the header of each method as listed here:
getCost doesnt take any arguments but returns the total cost of this item order.
setQuantity takes a new quantity to be modifiedas an integer etc.. and this
method doesnt return anything to the user.
toString displays the item value ex: of chicken or of eggs.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started