Write a class that describes an inventory item. An item has the following data m
ID: 3540149 • Letter: W
Question
Write a class that describes an inventory item. An item has the following data members %u2013 all private:
int id
int quantity
float price
string name
An item also has public methods:
a default constructor that sets the id, quantity, and price to 0, and the name to an empty string.
an overloaded mutator function called void setItem(); that can be used to set all four items or just the id or just the name (i.e., you will have three setItem methods. :-)
void printItem(); //prints all four attributes of an item
an overloaded == operator that will compare two inventory objects and return true if the objects have the same name.
int getQuantity(); //accessor that returns the quantity of the object
In the client: The items are read from the file "items.dat", and the read is to end of file. The main program can handle up to 1000 inventory items. After the inventory is read in, main should ask the user if they want to search for the quantity of an item 1)by name or 2)by id. The program will read the selection and then ask for the appropriate input. The program will then go through the inventory looking for the appropriate item and print the quantity of that item. For example if items.dat contained:
13254 25 57.32 widgeta
23344 10 3.45 widgetb
35655 52 4.10 widgetc
A run of the program might be:
How would you like to search? (enter 1 for search by item name, enter 2 for search by item id): 1
Please enter the item name that you are searching for: widgetb
There are 10 of item widgetb.
Another run might be:
A run of the program might be:
How would you like to search? (enter 1 for search by item name, enter 2 for search by item id): 2
Please enter the item id that you are searching for: 35655
There are 52 of item 35655.
Explanation / Answer
may i help you i am professional software developer???
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.