Skip to content

Commit

Permalink
Deleted unused duplicate files, continued javadoc documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikollai committed May 25, 2026
1 parent 3a96abb commit 4079e92
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 39 deletions.

This file was deleted.

16 changes: 9 additions & 7 deletions src/main/java/millions/model/Share.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class Share {

/**
* @param stock Which stock the share is for.
* @param quantity How many stocks
* @param purchasePrice Purchase price of the share
* @throws IllegalArgumentException
* @param quantity How many stocks.
* @param purchasePrice Purchase price of the share.
* @throws IllegalArgumentException if stock is null.
* @throws IllegalArgumentException if quantity is null.
* @throws IllegalArgumentException if purchasePrice is null.
*/
public Share(Stock stock, BigDecimal quantity, BigDecimal purchasePrice) {
this.stock = stock;
Expand All @@ -30,27 +32,27 @@ public Share(Stock stock, BigDecimal quantity, BigDecimal purchasePrice) {
}
}

/** Share() with int quantity */
/** Share() with int quantity. */
public Share(Stock stock, int quantity, BigDecimal purchasePrice) {
this(stock, BigDecimal.valueOf(quantity), purchasePrice);
}

/**
* @return
* @return Stock object.
*/
public Stock getStock() {
return this.stock;
}

/**
* @return
* @return BigDecimal: quantity.
*/
public BigDecimal getQuantity() {
return this.quantity;
}

/**
* @return
* @return BigDecimal PurchasePrice.
*/
public BigDecimal getPurchasePrice() {
return this.purchasePrice;
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/millions/model/Stock.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,48 +30,48 @@ public Stock(String symbol, String company, List<BigDecimal> prices) {
}
}

/** Stock() with single price instead of list */
/** Stock() with single price instead of list. */
public Stock(String symbol, String company, BigDecimal initialPrice) {
this(symbol, company, new ArrayList<>(List.of(initialPrice)));
}

/**
* @return
* @return String: symbol.
*/
public String getSymbol() {
return this.symbol;
}

/**
* @return
* @return String: company.
*/
public String getCompany() {
return this.company;
}

/**
* @return
* @return BigDecimal: price.
*/
public BigDecimal getSalesPrice() {
return this.prices.getLast();
}

/**
* @param price Sales price
* @param price Sales price.
*/
public void addNewSalesPrice(BigDecimal price) {
this.prices.add(price);
}

/**
* @return
* @return BigDecimal list of prices.
*/
public List<BigDecimal> getHistoricalPrices() {
return this.prices;
}

/**
* @return
* @return BigDecimal highest recorded price.
*/
public BigDecimal getHighestPrice() {
BigDecimal highestPrice = this.prices.get(0);
Expand All @@ -84,7 +84,7 @@ public BigDecimal getHighestPrice() {
}

/**
* @return
* @return BigDecimal lowest recorded price.
*/
public BigDecimal getLowestPrice() {
BigDecimal lowestPrice = this.prices.get(0);
Expand All @@ -97,7 +97,7 @@ public BigDecimal getLowestPrice() {
}

/**
* @return
* @return BigDecimal price difference from last week
*/
public BigDecimal getLatestPriceChange() {
if (this.prices.size() < 2) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/millions/model/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,30 @@ protected Transaction(Share share, int week, TransactionCalculator transactionCa
this.committed = false;
}

/**
* @return Share object
*/
public Share getShare() {
return this.share;
}

/**
* @return int: week
*/
public int getWeek() {
return this.week;
}

/**
* @return TransactionCalculator object
*/
public TransactionCalculator getCalculator() {
return this.transactionCalculator;
}

/**
* @return Boolean: status
*/
public boolean isCommitted() {
return this.committed;
}
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/millions/model/TransactionArchive.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public TransactionArchive() {
this.transactions = new ArrayList<>();
}

/**
* Adds a transaction to the archive
* @param transaction transaction object
* @return Boolean for success
*/
public boolean add(Transaction transaction) {
if (transactions.contains(transaction)) {
return false;
Expand All @@ -21,25 +26,45 @@ public boolean add(Transaction transaction) {
return true;
}

/**
* @return Boolean
*/
public boolean isEmpty() {
return transactions.isEmpty();
}

/**
* @return List of transaction objects
*/
public List<Transaction> getTransactions() {
return new ArrayList<>(transactions);
}

/**
* returns transaction processed in a given week
* @param week int
* @return List of transaction objects
*/
public List<Transaction> getTransactions(int week) {
return transactions.stream().filter(x -> x.getWeek() == week).collect(Collectors.toList());
}

/**
* Returns all purchase transactions in a given week
* @param week int
* @return List of transaction objects
*/
public List<Purchase> getPurchases(int week) {
return transactions.stream()
.filter(t -> t.getWeek() == week && t instanceof Purchase)
.map(t -> (Purchase) t)
.collect(Collectors.toList());
}

/**
* Returns all sale transactions in a given week
* @param week int
* @return List of transaction objects
*/
public List<Sale> getSales(int week) {
return transactions.stream()
.filter(t -> t.getWeek() == week && t instanceof Sale)
Expand Down

0 comments on commit 4079e92

Please sign in to comment.