You Are Tasked With The Responsibility Of Writing A Tool For Generating Java Code From Uml The Class Diagram Provides P 1 (102.99 KiB) Viewed 12 times
You Are Tasked With The Responsibility Of Writing A Tool For Generating Java Code From Uml The Class Diagram Provides P 2 (16.17 KiB) Viewed 12 times
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. Trading Position inc() [price>=v1]/price++ buy() Accumulate buy() Holding inc() [price<v1]/price++ crash Position + id: String [1] O + price: Real [1] crash() Available crash crash() buy() sell() sell() Reduce sell()
The following outline code has been generated from the tool: public class S2 extends S1 { } public void buy (Int Amount, X _this) { _this.setState(new S4()); _this.setop1(_this.ret_op1()+Amount); } public void sell (Int Amount, X _this) { _this.setState(new S3()); _this.setop1(_this.ret_op1()-Amount); } public void crash (X _this) { _this.setState(null); }
In the following, choose all statements which are true. Ⓒa. X==Position. O b. X==Holding. S1==Available, S2==Reduce, S3==Accumulate. d. Operations of the Position class should include inc, available, buy, reduce, and crash. De Operations of the Position class should include crash, inc, buy and sell. O f. Since the state machine contains loops, the number of states is infinite. 8- 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. Oh. $1==State (where State is an abstract class), S2==Accumulate, $3==Reduce, S4==Accumulate.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!