Description
Develop a class from given requirements
Implement that class using object-oriented programming techniques
Overload an operator for a class
You need to design, implement, and test a grocery shopping list program. The program
should maintain and display a list of items.
You will use a class for the Items. The class should have data elements for the
following information: item name, unit (i.e. can, box, pounds, or ounces), number to
buy, and unit price. Do you need any functions other than the constructor(s)? How do
you calculate the extended price for the item (number to buy times unit price? How do
you print it to the screen?
You will also need a List class. You will store Item objects in your List object. As
each item is entered an Item object must be created and added to the List object. Use a
dynamic array to hold the Item objects. The dynamic array should start with a capacity
of 4 Item objects. Do you need a print function in this class?
NOTE: A vector is not a dynamic array.
Your program must perform the following activities: create a list, add items, remove
items, and display the shopping list. To add an item you should prompt the user to enter
the name, unit of sale, the number needed, and the unit price. The display should show:
each item in the list, the number of items, the unit of sale, the unit price, the extended
price for each item, and the total price for all items. Oregon doesn’t have a sales tax so
you can ignore that. J Debug and test your program.
Once you have the List and Item classes working correctly, test if an item is already in
your List before adding it. Overload the == operator to perform the test. There is a
simple example to overload this operator in the book. Keep it simple. How will you
compare items? You can assume that the user will type the information in correctly.
You must create a design document. It should include the design of the classes and how
you will use the classes. Figure that out, before you start coding. If you do the design
properly the coding should be easier.
Your reflections document should include the design document, the testing results, and
describe any changes you made to your original design.
You will provide a simple test plan. Since this is a program with input and output you
should not need any driver functions. You do NOT need to test for every possible item in
a grocery store, just a reasonable number or varying lengths. How do you handle spaces
in names? Are the extended prices calculated correctly? Is the total amount correct?
Grading:
• programming style and documentation (10%)
• create the list class and object (15%)
• create the item class and objects (10%)
• add and remove an item object to the list (15%)
• resize the dynamic array correctly when the number of Item objects
exceeds the capacity (5%)
• Display the list to include the following: item name, unit for
purchase, price per unit, number to buy, extended price for that item.
Then at the bottom of the display indicate the total cost for that trip to
the store. (20%)
• overload the equality operator (==) to prevent including duplicate
Item objects in the shopping list (10%)
• reflections document to include the design description, test plan, test
results, and comments about how you resolved problems while
designing and implementing your program (15%)