From 7c7adc8d135d1c8013d3880bc284046bfbc6527f Mon Sep 17 00:00:00 2001 From: EspenTinius Date: Wed, 11 Feb 2026 16:50:59 +0100 Subject: [PATCH 1/3] class constructor This update is for the class constructor --- .../java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java index 09c577b..2575d34 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java @@ -1,5 +1,15 @@ package edu.ntnu.idi.idatt2003.g40.mappe; +import java.math.BigDecimal; + public class Share { - + private final Stock stock; + private final BigDecimal quantity; + private final BigDecimal purchasePrice; + + public Share(Stock stock, BigDecimal quantity, BigDecimal purchasePrice) { + this.stock = stock; + this.quantity = quantity; + this.purchasePrice = purchasePrice; + } } From 160d1efdf2aae3180432a7ac602372d33d181d37 Mon Sep 17 00:00:00 2001 From: EspenTinius Date: Wed, 11 Feb 2026 16:54:12 +0100 Subject: [PATCH 2/3] get methods adding the methods for the class --- .../java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java index 2575d34..6dc4f7b 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java @@ -12,4 +12,16 @@ public Share(Stock stock, BigDecimal quantity, BigDecimal purchasePrice) { this.quantity = quantity; this.purchasePrice = purchasePrice; } + + public Stock getStock() { + return stock; + } + + public BigDecimal getQuantity() { + return quantity; + } + + public BigDecimal getPurchasePrice() { + return purchasePrice; + } } From da9d5c53f6488ad91e6a51471e3f5504eb442994 Mon Sep 17 00:00:00 2001 From: EspenTinius Date: Wed, 11 Feb 2026 16:56:33 +0100 Subject: [PATCH 3/3] javadoc adding java documentation to the Share class --- .../ntnu/idi/idatt2003/g40/mappe/Share.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java index 6dc4f7b..d27478a 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Share.java @@ -2,25 +2,54 @@ import java.math.BigDecimal; +/** + * Represents a share owned by a player. + *

+ * A share contains information about which stock was purchased, + * the quantity purchased, and the purchase price. + *

+ */ 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; }