Write An Essay logo
  • Home
  • Dissertation Writing
  • Essay Writing
  • Personal Statement
  • My account
  • Order now
Order Now
Uncategorized

Java project programming

4 min read
Posted on 
September 29th, 2021
Home Uncategorized Java project programming

 

java project programming, need to done the first part of assignemnt only.

1 – Server: Stock Exchange

The stock exchange acts as a server. It should accept incoming requests from trader and do the appropriate actions based on these requests. You are free to hard-code the port number of this server (e.g. 8080).

The trader can make a number of different requests:

  • Request stocks: A trader requests information of all the current stocks. The exchange should respond with a collection of all its stocks.
  • Request transaction history: A trader requests their transaction history to get information on what prices their orders were resolved at. The exchange should respond with the transaction history of that particular trader. However, it is not very efficient to send the entire transaction history each time. As such, it is fine if you only send the transactions that have happened since the last time the trader placed this request. You can assume the trader is updating their portfolio accordingly.
  • Place a buy limit order: A trader wants to place a buy order. The exchange should attempt to resolve the buy order as detailed above. If you want, you can let the exchange reply with a success/error message.
  • Place a sell limit order: A trader wants to place a sell order. The exchange should attempt to resolve the buy order as detailed above. If you want, you can let the exchange reply with a success/error message.

Design your exchange in such a way that adding support for more requests is very straightforward (a certain design pattern might be useful here hint hint).

You don’t have to think of stocks and their data yourselves; we have provided a stocks.yaml file for you that contains example stocks and their necessary information. At the start of the simulation, your program should read this file and initialise the stocks. At this point, the price of the stock should be set to initialPrice (as provided in the stocks.yaml file). The price change is the difference between the current price and the initial price.

To load in this yaml file, you will be using Jackson, like we showed you in the first tutorial. Alternatively, you could look at the following online tutorial. Note that we have already provided a YamlLoader class in the util package of the stocks-core module that you can use for mapping the yaml file to an object. Note that you will need frequent access to the stocks, so it is useful to index them by their symbols.

To make the yaml loading work, you will need to create a custom class (e.g. StockCollection). This class should have a field Map<String, YourStockClass> with the name stocks. The YourStockClass refers to a class that you will have to implement yourself that has fields for the information specified in the yaml file (symbol, name, etc.). Make sure that you have at least a getter or a setter for each field (simply adding @Getter above the class should be sufficient), otherwise Jackson will not be able to load the class correctly. We have structured the stocks.yaml file in such a way that Jackson will be able to immediately instantiate this StockCollection class.

In order to get Jackson to work with our module structure, we need to “open” the package of the class we are trying to load to the Jackson library. Suppose the class we are trying to load is located in a package called stocks in the core module, then we would have to add the following at the end of the module-info.java of the core module:

opens nl.rug.aoop.stockscore.stocks to com.fasterxml.jackson.databind;

Order an Essay Now & Get These Features For Free:

Turnitin Report

Formatting

Title Page

Citation

Outline

Place an Order
Share
Tweet
Share
Tweet
Calculate the price
Pages (275 words)
$0.00
Write An Essay
Company
  • Why Choose Us
  • About Us
  • Terms
  • Dissertation Help
  • Personal Statement
  • Research Paper Format
  • Term Papers
Legal
  • Write My Essay
  • Thesis Format
  • Custom Papers
  • Coursework Writing
  • Dissertation Writing
  • Essay Writing
How Our Service is Used:
Write An Essay essays are NOT intended to be forwarded as finalized work as it is only strictly meant to be used for research and study purposes. Write An Essay does not endorse or condone any type of plagiarism.
Subscribe
No Spam
© 2023 Write An Essay. All rights reserved.
Write An Essay will be listed as ‘Write An Essay’ on your bank statement.