Assignment 2 Solution

$35.00 $29.00

Objective Practice UML, Design Patterns and Git Marking This assignment is worth 8% of your nal grade. The submission deadline is Jan 29, 2017, 11:59pm on Github. You are encouraged to work in pairs. Late submission policy: No late submissions are accepted. How to submit your work Please sign in to git using your mail.utoronto.ca…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)
  • Objective

Practice UML, Design Patterns and Git

  • Marking

This assignment is worth 8% of your nal grade.

The submission deadline is Jan 29, 2017, 11:59pm on Github.

You are encouraged to work in pairs.

Late submission policy: No late submissions are accepted.

  • How to submit your work

    1. Please sign in to git using your mail.utoronto.ca account. Use this invitiation link https://classroom.github.com/group-assignment-invitations/bd6be384c3ce3f943e12e9bc6d34e214 and clone the starter code following GitHub instructions.

    2. To submit your work, add, commit and push your changes to your repository.

Do not commit the les and directories generated by Eclipse, such as bin, doc, .project, etc. Marks will be deducted if you submit these.

    1. The date and time of your last commit must be on or before 29 Jan 2017, 11:59pm.

  • The wallpaper manufacturing and distribution problem

The problem stated in this exercise is a simpli ed version of an actual software industry problem, solved and implemented in various commercial wallpaper manufacturers in North America.

An important speci c of wallpaper manufacturing (shared with many other manufacturing processes) is that there is a minimum amount of wallpaper that can be printed in one production run (1000 yards for most common types of commercial wallpaper).

The whole process can be described as follows. For each Product, the warehouse maintains an Inventory item, which has two attributes: the product, the available quantity on the inventory, and the quantity required by the customers, also known as the backordered quantity. Also the warehouse keeps track or SalesOrders and ships them out as soon as su cient quantity becomes available.

The manufacturing facility, maintains a ProductionOrder for each inventory item. A production order is used to manufacture a quantity greater or equal to the minimum quantity, and also su cient to cover the quantity required by SalesOrders.

It is clear that an Inventory item is an Observable and SalesOrders and ProductionOrders are Observers. In addition, both SalesOrders and ProductionOrders implement a DisplayElement interface as shown in the UML diagram below.

1

CSC301 Introduction to Software Engineering

So here is how the solution works. Initially, we set up a number of Customer objects, and a number of Product ojects. For all the products that we intend to manufacture and sell, we set up and Inventory item that will be an Observable.

Who observes Inventory items? Well, in order to sell, we should manufacture some quantities, so we set up a ProductionOrder that is supposed to generate some quantity if there is a demand for that particular inventory item.

What does demand mean? Well, customers place SalesOrder items, which are supposed to be fu lled by the warehouse, given that there is enough quantity on Inventory. So, at this point, please identify the other Observable.

Also both Observables implement DisplayElement interface that allows the display of observables.

The wallpaper manufacturing and distribution work ow is as follows:

  1. Perform the setup (generate Customers, Products, Inventory items and ProductionOrders). Note that ProductionOrders are observables!

  1. Customers place SalesOrders.

  1. If there is enough quantity on inventory, the SalesOrder gets shipped immediately so it does not need to go to the list of observers. Otherwise it should be registered as an Observer.

  1. When an SalesOrder gets registered as an observer, the backorderedQuantity should be updated accordingly.

  1. Meanwhile, the ProductionOrder gets noti ed so if the backorderedQuantity is greater or equal than minQuantity, the ProductionOrder activates the manufacturing facility to make some quantity (su cient to cover all SalesOrders!) and updates the availableQuantity.

  1. The SalesOrders should get noti ed on the availability and ship out. The inventory should be main-tained accordingly.

  1. If a quantity is made by a ProductionOrder or if a quantity is shipped in behalf of a SalesOrder the display method should display the appropriate information on the console.

A complete example is shown below. The code (in the main method) that generates this output is provided in full in the starter code.

S h i p p i n g Order# 3

t o Home Depot ,

Product : Flower F i e l d , Quantity : 8 0 0 . 0

S h i p p i n g Order# 1

t o

Wal

Mart , Product : Flower F i e l d , Quantity : 5 0 0 . 0

P r o d u c t i o n Order#

1 ,

item

Flower

F i e l d , produced 1 3 0 0 . 0

S h i p p i n g Order# 4

t o Home Depot ,

Product : Stormy Sea , Quantity : 1 4 0 0 . 0

S h i p p i n g Order# 2

t o Home Depot ,

Product : Stormy Sea , Quantity : 7 0 0 . 0

P r o d u c t i o n Order# 2 , item Stormy Sea , produced 2 1 0 0 . 0

321

Stormy

Sea ,

A v a i l a b l e : 0 . 0 , B a c k o r d e r s : 0 . 0

[PO2

Stormy

Sea

2000.0]

123

Flower

F i e l d ,

A v a i l a b l e : 0 . 0 ,

B a c k o r d e r s : 0 . 0

[PO1

Flower

F i e l d

1000.0]

  • What is to be done?

Read the execise carfelly and study the provided UML diagram.

Check our the starter code and using the UML diagram, write your solution.

Please do use the same names for your classes, class variables and methods as indicated in the associated UML diagram.

2

CSC301 Introduction to Software Engineering

Throughout your coding process, follow the UML diagram carefully.

Test your application thoroughly. You do not need to submit your test code. Submit only classes and interfaces shown on the UML diagram.

  • The UML Diagram

Inventory

#observers: List<Observer>

#product: Product

#availableQuantity: double

#backorderedQuantity: double

+Inventory(product: Product)

#updateQuantities(stock: double,

SalesOrder

backord: double): void

-orderSequence: int

+registerObserver(o: Observer): void

+removeObserver(o: Observer): void

#ID: int

#customer: Customer

+notifyObserver(): void

interface

#quantity: double

+toString(): String

DisplayElement

#inventory: Observable

+SalesOrder(customer: Customer,

+display(q: double): void

quantity: double, inventory: Observable)

+update(availQty: double, ordQty: double): void

+display(displayQuantity: double): void

-ship(availableQuantity: double): boolean

+toString(): String

Customer

#ID: int

#name: String

+Customer(ID: int,

name: String)

+toString(): String

Product

#ID: int

#name: String

+Product(ID: int,

name: String)

+toString(): String

ProductionOrder

-orderSequence: int

#ID: int

#minQuantity: double

interface

#inventory: Observable

interface

Observable

+ProductionOrder(

Observer

minQty: int,

+registerObserver(o: Observer): void

inventory: Observable)

+update(availQty: double, ordQty: double) : void

+removeObserver(o: Observer): void

+update(availQty: double,

+notifyObserver(): void

ordQty: double): void

+display(dispQty: double):

void

+toString(): String

3

CSC301 Introduction to Software Engineering

  • Checklist

Have you…

tested your code using Java 1.8?

committed and pushed the correct les in the correct directory?

tested your solution, made any necessary changes, and re-committed if necessary?

4

Assignment 2 Solution
$35.00 $29.00