-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Team-40-IDATT2003/enhancement/24-share-class
Enhancement/24 share class
- Loading branch information
Showing
1 changed file
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |