Skip to content

Enhancement/24 share class #38

Merged
merged 3 commits into from
Feb 11, 2026
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading