Page 1 of 1

Q9. You are tasked with the responsibility of writing a tool for generating Java code from UML. The class diagram provi

Posted: Tue May 24, 2022 8:16 am
by answerhappygod
Q9. You are tasked with the responsibility of writing a
tool for generating Java code from UML. The class diagram
provides partial information on the attributes of a trading
position. Missing from the diagram are the operations.
A state diagram is also shown of some possible states for the
trading position. The state diagram shows that a position is
held if its price is initially less than a certain value or is made
available to sell or buy otherwise. Once available to
buy/sell the position can be increased or decreased. State
transitions can terminate by way of a market crash.
Q9 You Are Tasked With The Responsibility Of Writing A Tool For Generating Java Code From Uml The Class Diagram Provi 1
Q9 You Are Tasked With The Responsibility Of Writing A Tool For Generating Java Code From Uml The Class Diagram Provi 1 (85.21 KiB) Viewed 16 times
The following outline code has been generated from the tool:
Q9 You Are Tasked With The Responsibility Of Writing A Tool For Generating Java Code From Uml The Class Diagram Provi 2
Q9 You Are Tasked With The Responsibility Of Writing A Tool For Generating Java Code From Uml The Class Diagram Provi 2 (17.04 KiB) Viewed 16 times
In the following, choose all statements which are true.
a.
S1==Available, S2==State (where State is an abstract class),
S3==Accumulate, S4==Reduce.
b.
Y==Position.
c.
Operations of the Position class should include crash, inc, buy
and sell.
d.
Since the state machine contains loops, the number of states is
infinite.
e.
S1==Reduce, S2==Holding, S3==Available.
f.
Y==Available.
g.
The Position class should have operations ret_op1 which returns
the amount invested in a position and setop1 which increases the
investment by a specified amount.
h.
Operations of the Position class should include inc, available,
accumulate, reduce, and crash.
crash inc() [price>=v1]/price++ Holding inc() [price<v1]/price++ crash() Trading Position Available crash crash() buy() sell() Accumulate buy0 sell() Reduce sell() buy()

Position + id: String [1] + price: Real [1]

public class S1 extends S2 { } public void buy (Int Amount, Z _this) { _this.setState(new S3()); _this.setop1(_this.ret_op1()+Amount); } public void sell(Int Amount, Z_this) { _this.setState(new S4()); _this.setop1(_this.ret_op1()-Amount); } public void crash (Z _this) { this.setState(null); }