Instructions:

1. Draw the UML class diagram:

  • Read and make sure that you thoroughly understand the existing inventory management program provided in the base code.
  • Using a drawing package of your choice, draw a UML class diagram to represent the objects you identified. You must show all classes (except the array classes), their attributes and operations, the associations between the classes (inheritance or composition), and the multiplicity and directionality of all associations. Do not show getter and setter functions, nor constructors or destructors.
  • You must update your UML diagram after you have completed the rest of the assignment . The UML diagram that you submit must match your code.

2. Implement the purchase and purchase collection classes

You will create a new purchase class (called Purchase) and a new purchase collection class (called PurchArray) to contain a collection of purchase objects. Each customer will have a purchase collection to track the products that they have bought, as well as the number of units of each product. Your classes will behave as follows:

  • the Purchase class will contain the id of a purchased product, and the number of units of that product bought by that customer over the customers lifetime
  • the PurchArray class will contain an array of Purchase objects and its current number of elements
  • you will modify the Customer class will contain a collection of purchases
  • each customers purchase collection will contain only products that the customer has actually bought; there should be no placeholder purchases and no purchases with duplicate product ids
  • when a customer buys a product:
    • if the customer has bought this product in the past, then it will already be in their purchase collection; you must find this product id in the purchase collection and increment the number of units bought
    • if the customer has never bought this product before, then you must add the product as a new purchase in the purchase collection

3. Implement the product purchase feature

The product purchase feature allows a customer to buy several products. Buying a product earns the customer some loyalty points, which have a 1-to-1 correspondence with the product price (for example, if a product costs $5, the customer earns 5 points). The inventory management system tracks which products the customer buys and how many units of each product over time. This information is tracked with the purchase collection that you implemented in the previous step.

You will implement the product purchase feature that can be selected from the cashier menu. You will modify the Customer class to store the number of loyalty points that a customer has earned over their lifetime.

The product purchase feature will:

  • prompt the user for the id of the customer making the purchase, and verify that it is an existing customer
  • prompt the user for a collection of product ids that the customer wants to purchase, terminated by zero
  • for each product purchased:
    • verify that the product exists
    • verify that there is at least one unit of this product in stock
    • reduce the number of units of that product available in the store
    • compute the number of loyalty points earned by the customer with purchasing this product
    • add the loyalty points to the customers points
    • keep a tally of the total purchase amount (the product prices) and the total number of loyalty points
    • register the purchase in the customers collection of purchases: if this is a repeat purchase, then simply increment the number of units bought. if this is a new purchase, then you must add the product as a new purchase
  • print a summary to the screen of the total purchase amount and number of points earned

Notes:

  • For this assignment only , if a customer or product cannot be found, the program will terminate
  • Sloppy design will be penalized. The code for this feature belongs in several different classes, in keeping with correct design principles. You must think this through and plan where to place which parts of the code.

4. Modify the print customers feature

You will modify the print customers feature so that it prints out all the purchase information for each customer, in addition to all the customers information.

Note:

You will provide sufficient datafill for products and customers. This means that your program must:

  • create and initialize a minimum of 20 different types of products and a minimum of 10 different customers
  • you can use the existing datafill provided in the base code

Insufficient datafill means that your assignment cannot be adequately tested; this may incur deductions of up to 100% of the assignment

Constraints

  • your program must follow the existing design of the base code, including the encapsulation of control, UI, entity and array object functionality
  • do not use any classes or containers from the C++ standard template library (STL)
  • do not use any global variables or any global functions other than main
  • do not use structs; use classes instead
  • objects must always be passed by reference, not by value
  • your classes must be thoroughly documented in every class definition
  • all basic error checking must be performed
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.