代写代考 G6046 Software Engineering

G6046 Software Engineering
Seminar session: Class design The task
You have been given an outline specification for a computer system to help manage stock for a new community upscaling facility.
“Margo and Barbara are starting a new community facility called ‘Bargo’ for upscaling and recycling household items. The idea is that members of the public can bring old sofas, chairs and electrical items that they no longer want and Bargo can then either restore the items and sell them for a profit or arrange for them to be disposed of in a safe and proper manner.

Copyright By PowCoder代写 加微信 powcoder

When someone donates an item to Bargo, they do not need to provide any identification. One of the Bargo team needs to record what the item is in the computer system. For sofas, they need to know how many people the sofa could seat, the condition rated from 1 (very poor) to 5 (excellent), the colour and the type of fabric. For chairs, we need the same data as sofas, except that all chairs only seat one person. For electrical items, we need a simple one line description of what the item is, the condition using the same rating system, and a record to show whether the item has been checked by an electrician to determine whether it is safe to use, as all unsafe electrical items need to be disposed of.
All items that are rated as 3 or better will be put up for sale. The computer system will need to identify which items in stock can be sold. Any item with a poorer rating, or deemed unsafe, must be disposed of. Each week, the computer system needs to produce a list of items to be disposed of. The sale items can be viewed by customers. In order to buy items at Bargo, customers need to open an account. To do this they need to provide a name, address and an email address. Once they have opened an account, the computer system will keep a record of all purchases they make. A customer can also reserve an item for payment within 14 days. After 14 days, the item goes back to being on sale. For convenience, Bargo staff need to be able to recover data about customer reservations by using the customer name.”
Sketch out Java class definitions appropriate for coding this system. Describe the classes that will be needed and list the fields (public and/or private) and the methods that each class will need to implement. You do not need to provide any substantive source code for the classes, just their external interfaces and some outline of what they will require. You should show how your classes will interact together by means of a very high-level class diagram.
Several classes defined above will use collections of objects of other classes. Which of the available Java Collection types would be most appropriate for each of the collections? Give reasons for your choices.
Things to watch out for
 Consider how polymorphism can help (super/sub classes). This is a key feature of OO languages.
 Don’t confuse a class designed to represent a single thing with a collection class. Java allows for collections of any type.
 Aspire for high cohesion and low coupling.

Suggested answer
A possible solution might be:
Attributes
ArrayList stock
ArrayList
allCustomers
HashMap
purchaseRecords
HashMap reservedItems
ArrayList
showReserved(String)
createCustomer(…)
addStock(…)
Chair extends Item
Electrical extends
int condition
boolean reserved
String colour
String fabric
String description
boolean isSafetyChecked
Sofa extends Item
int numPeople
String colour
String fabric
String name
String address
String email
ArrayList
ArrayList reserved
reserveItem(…)
makePurchase(…)
Draw a class diagram to see the extent of coupling. Note:
 The use of the Item superclass.
 Who was responsible for adding stock.
 Who was responsible for making purchases and reserving items.
 The use of the two collection types ArrayList and HashMap.

Here is an alternative solution (courtesy of ). How do you think it compares?

Dr Kingsley Sage Dr

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com