Goal

Modify your inventory management program from Assignment #3, to implement a Faade design pattern, along with some new features.

Instructions:

1. From previous assignments:

You will need to implement the following features from previous assignments.

From Assignment #1:

  • implement the product purchase feature, using the Purchase and PurchArray classes

For more details, see the Assignment #1 description.

From Assignment #2:

  • modify the program to dynamically allocate all data objects, specifically Product and Customer objects
  • modify the product and customer collection classes to contain an array of pointers to objects
  • explicitly deallocate all dynamically allocated memory; memory leaks will be penalized

For more details, see the Assignment #2 description.

If you are starting from Assignment #3, you can continue using the linked list collection class.

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

2. Tracking orders

Every time that a user invokes the product purchase feature, he/she indicates a set of products that he/she is buying. This set of products makes up an order , which you will now be storing in your program.

You will create a new Order class, and a new OrderArray collection class to contain a collection of order objects:

  • the Order class will contain:
    • a unique order id
    • the customer who placed the order, stored as a Customer pointer
    • a collection of the purchases that make up this order (you must reuse the PurchArray class for this)
    • the total dollar amount of the order (the sum of the prices of all products purchased as part of this order)
  • all Order objects will be dynamically allocated
  • the OrderArray class will contain an array of Order object pointers

Notes:

  • There are two distinct uses for the Purchase class in the inventory management program:
    • Use #1: As part of the Customer class, a purchase indicates how many units of a specific product the customer has purchased over the lifetime of the program , no matter how many times the user invokes the product purchase feature. This use of the Purchase class was implemented in Assignment #1.
    • Use #2: As part of the Order class, a purchase indicates how many units of a specific product the customer has purchased during a single invocation of the product purchase feature.
  • Example: Say that customer #2004 selects the product purchase feature twice: the first time, she purchases 1 unit of product 5015, and 1 unit of product 5011; the second time, she purchases 2 units of product 5011 and 1 unit of product 5007. There will be two orders stored in the order array: one for the first product purchase, and one for the second. The first order will show 1 unit of product 5015 and 1 unit of product 5011, and the second order will show 2 units of product 5011 and 1 unit of product 5007. The customer, however, will have three purchases in her purchase collection: one for 1 unit of product 5015, a second for 3 units of product 5011, and a third for 1 unit of product 5007.

3. Implement the Faade class

The Faade design pattern is used to hide away complex processing from the rest of the program. This is done by creating a new Faade class that performs actions for the other classes in the program and hides the details of how these actions are done.

In our inventory management program, we will implement this Faade class as an order server . The purpose of this object is to store a collection of orders, as described in instruction #2, in a way that is transparent (hidden) from the rest of the program. For now, the orders will be stored locally on the same computer, but we are implementing the design pattern so that the orders could one day be stored remotely on a network, and all the processing to access the orders on the network would be hidden inside the order server object.

For this assignment, you will create the OrderServer class, which will store the collection of all orders. There will be a single instance of the OrderServer class, and that object will be contained in our programs inventory control object. The order server object will be the only object in the program to store the orders.

You will implement two member functions in the OrderServer class: update and retrieve. They will use the following prototypes:

void update(Order* order)
void retrieve(OrderArray& arr)

The update function adds a new order to the order servers collection. The retrieve function allows the inventory control object to retrieve all the orders in order to have them printed to the screen.

4. Modify the product purchase feature

You will modify the product purchase feature so that, every time this feature is invoked, a new order is created for the specified customer. Every product selected by the user will be added to that order. Once the order is complete (when the user enters 0 to indicate that he/she is done), the new order will be sent to the order server for storage.

5. Implement the print orders feature

You will implement the print orders feature, which is available from the admin menu and from the hidden option in the cashier menu. This feature retrieves all orders from the order server object, and it prints all the data to the screen. Note: You must reuse existing functions everywhere possible.

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
  • 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.