Laboratory 4

Exercise

Consider a simple stock market where stockowners and corporations trade their shares. A stockowner can sell its shares in the market and can buy any shares that are being sold, if he can afford them. The corporations are stockowners that can also create shares of the corporation to trade in the stock market.

Assume that:

  • Whenever a stockowner wants to buy x shares of a corporation and there is only y < x shares of that corporation in the market, then the stockowner buys only the y available shares.
  • Whenever a stockowner buys x shares of a corporation and he already has y shares from that corporation, then afterwards the stockowner has x + y shares of that corporation.

a) Model in UML the class diagram.

b) Implement it in Java.

c) Test your program (in a main method).

Attachments