Assignment 1 - The Retail Store

Due - Sunday, September 22, 2024

This is a group project of 2 or 3 students per group. The groups can be found in the document Assignment1_Groups.docx.

Introduction

You have been given code for generating a tool box as well as filling a grocery bag. For each, the user is prompted for information, then the appropriate object is created. In the end the customer will have a shopping cart of tools and groceries. These tools and groceries are purchased at a retail store, which would like to keep statistics about purchasing preferences.

Design Considerations

You must decide if you are going to use one of the standard design patterns that you have learned so far, or create a custom one. Either way, you must provide a UML diagram of your implementation.
You can write your code in one of the following four languages: C++, C#, Java or Python. Explain your choice, keeping in mind the principles of software engineering regarding reusability and extensibility. Also keep in mind that at least one of your assignments has to be written in Java and at least one in C#.

The Shopping Cart

The shopping cart contains an assortment of tools and groceries. Code for generating tools is given in four languages:
C++: Toolbox.cpp.
C#: Toolbox.cs.
Java: Toolbox.java.
Python: Toolbox.py.
Note that each tool has a name and a cost. Note that the above code limits the number of tools you can purchase to 2 and limits the types of tools to the Hammer and Screwdriver. Note that tools are taxable with GST=14%.

Code for generating groceries is given in four languages:
C++: GroceryBag.cpp.
C#: GroceryBag.cs.
Java: GroceryBagMain.java.
Python: GroceryBag.py.
Note that each grocery item has a name, cost and calories. Note that the above code limits the number of groceries you can purchase to 2 and limits the types of groceries to the Apple and Orange. Note that groceries are not taxable.

The Customer

The customer has a shopping cart as well as a name, cash and a pointer to a retail store (because the customer can only visit one retail store at a time). The customer can fill the shopping cart, spend cash, and add cash.

The Retail Store

The retail store has a collection of customers who visit the store. For each purchase, the retail store will calculate and report the cost, adding GST where necessary. The retail store displays everything that is in the shopping cart once the customer's purchase is complete. The retail store wishes to keep the following statistics:

  1. The average that each customer spends.
  2. The total revenue (the sum of what each customer spends).
  3. What percentage of the total revenue is tools and what percentage groceries.
These statistics will help the retail store concentrate more on groceries or tools.

Test Program

Create a test program to run the above. You can modify the existing code if you wish. Run the test program for three customers. Be sure to display each customer's order, including the total. After the three customers have finished their purchasing, calculate and display statistics for the retail store.

Questions

  1. What type of a design pattern did you employ (creational, structural, behavioural, custom)? Why?
  2. What is inversion of control?
  3. The open/close principle states that any class, component or entity should be open for extension but closed for modification. How could one extend a class without modifying the code?
  4. How are design patterns different from algorithms?

Marking Rubric

You will be marked out of 10 according to the following:

Does not meet expectationsSatisfactoryGoodExceeds Expectations

UML Diagram
(2 marks)
Does not meet requirementsMeets the most important requirementsMeets all requirements with minor errorsMeets all requirements with no errors

Shopping cart
(2 marks)
Does not meet requirementsMeets the most important requirementsMeets all requirements with minor errorsMeets all requirements with no errors

Customer
(1 mark)
Does not meet requirementsMeets the most important requirementsMeets all requirements with minor errorsMeets all requirements with no errors

Retail Store
(2 marks)
Does not meet requirementsMeets the most important requirementsMeets all requirements with minor errorsMeets all requirements with no errors
Code Documentation
(1 mark)
Does not contain documentationContains header documentation for either all files or for all functions within each file Contains header documentation for all files and for most functions within each fileContains header documentation for all files and for all functions within each file. Documents unclear code.
Questions
(2 marks)
Answers no question correctlyAnswers some questions correctlyAnswers most questions correctlyAnswers all Questions correctly

Submission

Please email all source code and answers to questions to: miguel.watler@senecapolytechnic.ca

Your answers to questions can be submitted in a separate document or embedded within your source code.

Late Policy

You will be docked 10% if your assignment is submitted 1-2 days late.
You will be docked 20% if your assignment is submitted 3-4 days late.
You will be docked 30% if your assignment is submitted 5-6 days late.
You will be docked 40% if your assignment is submitted 7 days late.
You will be docked 50% if your assignment is submitted over 7 days late.