Skip to content

Commit

Permalink
Reformat interface javadocs in Lab 02 assignment to fit text are with…
Browse files Browse the repository at this point in the history
…out horizontal scroller
  • Loading branch information
100yo committed Oct 20, 2023
1 parent 4b818c9 commit d130ea4
Showing 1 changed file with 36 additions and 26 deletions.
62 changes: 36 additions & 26 deletions 02-oop-in-java-i/lab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Trading121 :euro:

В последните години, световната икономика претърпява удар след удар. Инфлацията започва да изяжда спестяванията ни, но ние имаме страхотна идея - ще имплементираме платформа, която ще ни позволи да търгуваме с акции, подобна на [Trading212](https://www.trading212.com)
В последните години, световната икономика претърпява удар след удар. Инфлацията започва да изяжда спестяванията ни, но ние имаме страхотна идея - ще имплементираме платформа, която ще ни позволи да търгуваме с акции, подобна на [Trading212](https://www.trading212.com).

### `Portfolio`

Expand All @@ -13,21 +13,27 @@
* `Portfolio(String owner, PriceChartAPI priceChart, StockPurchase[] stockPurchases, double budget, int maxSize)` - когато вече има реализирани `stockPurchases` покупки на акции

Класът `Portfolio` трябва да имплементира следния интерфейс:

```java
package bg.sofia.uni.fmi.mjt.trading121;

import bg.sofia.uni.fmi.mjt.trading121.stock.StockPurchase;

import java.time.LocalDateTime;

public interface PortfolioAPI {

/**
* Purchases the provided quantity of stocks with the provided ticker. The budget in the portfolio should decrease
* by the corresponding amount. If a stock is on-demand then naturally its price increases. Every stock purchase
* should result in a 5% price increase of the purchased stock
*
* Purchases the provided quantity of stocks with the provided ticker. The budget in the portfolio should
* decrease by the corresponding amount. If a stock is on-demand then naturally its price increases.
* Every stock purchase should result in a 5% price increase of the purchased stock
*
* @param stockTicker the stock ticker
* @param quantity the quantity of stock that should be purchased
* @return the stock purchase if it was successfully purchased. If the stock with the provided ticker is not traded
* on the platform or the ticker is null, return null. If the budget is not enough to make the purchase, return
* null. If quantity is not a positive number, return null. If the portfolio is already at max size, return null.
* @param quantity the quantity of stock that should be purchased
* @return the stock purchase if it was successfully purchased. If the stock with the provided ticker is
* not traded on the platform or the ticker is null, return null. If the budget is not enough to make the
* purchase, return null. If quantity is not a positive number, return null. If the portfolio is already
* at max size, return null.
*/
StockPurchase buyStock(String stockTicker, int quantity);

Expand All @@ -38,16 +44,16 @@ public interface PortfolioAPI {

/**
* Retrieves purchases made in the provided inclusive time interval
*
*
* @param startTimestamp the start timestamp of the interval
* @param endTimestamp the end timestamp of the interval
* @param endTimestamp the end timestamp of the interval
* @return all stock purchases made so far in the provided time interval
*/
StockPurchase[] getAllPurchases(LocalDateTime startTimestamp, LocalDateTime endTimestamp);

/**
* @return the current total net worth of the portfolio: the sum of each purchases' quantity multiplied by the
* current price of the stock identified by that purchase rounded to two decimal places
* @return the current total net worth of the portfolio: the sum of each purchases' quantity multiplied by
* the current price of the stock identified by that purchase rounded to two decimal places
*/
double getNetWorth();

Expand All @@ -60,6 +66,7 @@ public interface PortfolioAPI {
* @return the owner of the portfolio
*/
String getOwner();

}
```

Expand All @@ -72,6 +79,8 @@ public interface PortfolioAPI {
```java
package bg.sofia.uni.fmi.mjt.trading121.stock;

import java.time.LocalDateTime;

public interface StockPurchase {

/**
Expand All @@ -90,9 +99,9 @@ public interface StockPurchase {
double getPurchasePricePerUnit();

/**
* Calculates the total price of the purchase given the quantity and the price per unit rounded to two decimal
* places
*
* Calculates the total price of the purchase given the quantity and the price per unit rounded
* to two decimal places
*
* @return the multiplication result of the quantity by the price-per-unit
*/
double getTotalPurchasePrice();
Expand All @@ -110,29 +119,30 @@ public interface StockPurchase {
### Цена на акции

Цената на акциите е динамична и се определя от търсенето. За тази цел обаче е необходимо да имаме механизъм за следене на текущата цена и нейната промяна, когато това се налага. В пакета `bg.sofia.uni.fmi.mjt.trading121.price` създайте клас `PriceChart` с публичен конструктор `PriceChart(double microsoftStockPrice, double googleStockPrice, double amazonStockPrice)`, който имплементира следния интерфейс:

```java
package bg.sofia.uni.fmi.mjt.trading121.price;

public interface PriceChartAPI {

/**
* Gets the current price of the stock identified by the provided stock ticker rounded to two decimal places
*
*
* @param stockTicker the stock ticker
* @return current price of stock. If the stock with the provided ticker is not traded on the platform or the ticker
* is null, return 0.0
* @return current price of stock. If the stock with the provided ticker is not traded on the platform
* or the ticker is null, return 0.0
*/
double getCurrentPrice(String stockTicker);

/**
* Changes the current price of the stock identified by the provided stock ticker by the provided percentage. As we
* are creating a thriving trading platform, the percentage can only be a positive number
*
* @param stockTicker the ticker of the stock for which the price is changing
* Changes the current price of the stock identified by the provided stock ticker by the provided percentage.
* As we are creating a thriving trading platform, the percentage can only be a positive number
*
* @param stockTicker the ticker of the stock for which the price is changing
* @param percentChange positive number denoting the percentage increase of stock price
* @return true, if the price was increased successfully. If the stock with the provided ticker is not traded on the
* platform or the ticker is null, return false. If the provided percentChange is not a positive number, return
* false.
* @return true, if the price was increased successfully. If the stock with the provided ticker is not traded
* on the platform or the ticker is null, return false. If the provided percentChange is not a positive
* number, return false.
*/
boolean changeStockPrice(String stockTicker, int percentChange);

Expand Down

0 comments on commit d130ea4

Please sign in to comment.