Stock Purchases Deque

Launched October 2023

Tags

  • Back End
  • Data Structures and Algorithms
  • Documentation
  • Java
  • Software Development
  • Unit Testing

A deque is a double ended queue that can only directly access the front and back, whether to view, remove, or add elements. I used a linked list implementation, where each inner node references the next node in the deque

In order to iterate through the elements, you must use an Iterator that repeatedly accesses the next node, since indexing is not possible with a linked list. This is used for displaying the deque, because normally you wouldn’t access elements in the middle.

UML class diagram defining methods and fields of classes in the Deque package, containing a LinkedDeque, and StockLedger package, containing StockPurchase, LedgerEntry, StockLedger and the Main program. UML object diagram showing objects and relationships starting with the Main program, connecting to the StockLedger, which connects to LedgerEntry, which contains the LinkedDeque, which contains StockPurchases.

I created a UML class and object diagram in order to plan the structure of my code. After implementing the LinkedDeque, I wrote unit testing using JUnit to ensure it functioned correctly without causing errors. I then created a StockLedger package in order to demonstrate the LinkedDeque functionality by storing purchased stocks in the deque.

The StockLedger is an ArrayList of LedgerEntry, each of which contains a LinkedDeque of StockPurchases. All stocks of the same type go into the same LinkedDeque, which stores one node for every stock purchased.

Diagram which shows an ArrayList of LinkedDeques, each of which contain multiple StockPurchases for a unique stock, such as AAPL.

The Main program buys and sells various stocks, displaying the ledger periodically to make the expected results easier to follow.

Screenshot of the current state of the ledger displayed in the terminal after buying/selling stocks. For example, Selling 30 AAPL shares at $65. Stock Ledger: AAPL 75.0 (10 shares), MSFT 95.0 (20 shares) Profit: 300.00

Thanks for checking out my project!

Back to Portfolio

Thank you!

Thanks for checking out my work! If you've got a project or job you think suits me, contact me here, by email, or on LinkedIn.

Contact Me

Thanks for dropping by!

Back to top