Skip to content

Commit

Permalink
Merge pull request #38 from Team-40-IDATT2003/enhancement/24-share-class
Browse files Browse the repository at this point in the history
Enhancement/24 share class
  • Loading branch information
tommyah authored Feb 11, 2026
2 parents bdcf244 + da9d5c5 commit 4a28ffa
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
package edu.ntnu.idi.idatt2003.g40.mappe;

import java.math.BigDecimal;

/**
* Represents a share owned by a player.
* <p>
* A share contains information about which stock was purchased,
* the quantity purchased, and the purchase price.
* </p>
*/
public class Share {

private final Stock stock;
private final BigDecimal quantity;
private final BigDecimal purchasePrice;

/**
* Creates a new {@code Share}.
*
* @param stock the stock that was purchased
* @param quantity the quantity purchased
* @param purchasePrice the price per unit at purchase time
*/
public Share(Stock stock, BigDecimal quantity, BigDecimal purchasePrice) {
this.stock = stock;
this.quantity = quantity;
this.purchasePrice = purchasePrice;
}

/**
* Returns the stock associated with this share.
*
* @return the stock
*/
public Stock getStock() {
return stock;
}

/**
* Returns the quantity of the stock owned.
*
* @return the quantity
*/
public BigDecimal getQuantity() {
return quantity;
}

/**
* Returns the purchase price per unit.
*
* @return the purchase price
*/
public BigDecimal getPurchasePrice() {
return purchasePrice;
}
}

0 comments on commit 4a28ffa

Please sign in to comment.