Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP5028 Lab 10 (Week 11) 
 
This week’s lab looks at implementing models into source code. Get into pairs for this lab. 
You will not need any IDE for this lab, just a simple text editor (e.g. notepad) or pen and 
paper will suffice. For each question produce Java code, or C++ code if you don’t know Java. 
 
1. The following diagram shows some relationships between classes. Produce a code 
skeleton that implements the design. Be careful not to add any extra details that are not 
shown in the diagram. 
 
 
2. The following diagram shows a design for sharing states amongst many objects. Create 
code that implements this design. 
 
 
3. The following design shows part of our system for drawing shapes from a previous 
assignment. Create code that implements the skeleton of this design. Can you improve the 
design at all? Assume that there is an implementation of Line.draw() already, i.e. you can 
create the method signature but not fill in the details of how to do the actual drawing. 
LockState
+LOCKED[1]: LockState
+UNLOCKED[1]: LockState
-LockState(locked: Boolean)
+getState(): String
Lock
-status: LockState
+Lock(initial: LockState)
+getStatus(): String
+draw()
Shape
+draw()
-point1 : Point
-point2 : Point
Line
-x : int
-y : int
Point
+draw()
-topLeft : Point
-bottomRight : Point
Rectangle
+draw()
-point1 : Point
-point2 : Point
-point3 : Point
Triangle
<>
Customer
BankAccount
DepositAccount Person
owner