-
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 #130 from Team-40-IDATT2003/enhancemet/124-mulig-å…
…-åpne-save-files-og-det-faktisk-husker-deg slik
- Loading branch information
Showing
21 changed files
with
1,540 additions
and
44 deletions.
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
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
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
81 changes: 81 additions & 0 deletions
81
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/model/OwnedShareData.java
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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.model; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| /** | ||
| * Immutable data record describing a single owned share in a {@link SaveGame}. | ||
| * | ||
| * <p> | ||
| * Holds just enough information to recreate a {@link Share} when the save is | ||
| * loaded: the stock symbol, the quantity owned and the original purchase | ||
| * price. The actual {@link Stock} object is looked up on the live | ||
| * {@link edu.ntnu.idi.idatt2003.g40.mappe.engine.Exchange} when the save is | ||
| * applied. | ||
| * </p> | ||
| * | ||
| * <p> | ||
| * Kept as a separate data type (rather than serialising {@link Share} | ||
| * directly) so the on-disk format stays decoupled from the runtime model | ||
| * and is easy to read/write through the hand-written JSON parser in | ||
| * {@link edu.ntnu.idi.idatt2003.g40.mappe.service.SaveGameService}. | ||
| * </p> | ||
| */ | ||
| public final class OwnedShareData { | ||
|
|
||
| /** Stock symbol this share is for. */ | ||
| private final String symbol; | ||
|
|
||
| /** Quantity of the stock owned. */ | ||
| private final BigDecimal quantity; | ||
|
|
||
| /** Price per unit at the time of purchase. */ | ||
| private final BigDecimal purchasePrice; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @param symbol the stock symbol. | ||
| * @param quantity the quantity owned. | ||
| * @param purchasePrice the price per unit at purchase time. | ||
| * | ||
| * @throws IllegalArgumentException if any argument is null. | ||
| * */ | ||
| public OwnedShareData(final String symbol, | ||
| final BigDecimal quantity, | ||
| final BigDecimal purchasePrice) | ||
| throws IllegalArgumentException { | ||
| if (symbol == null || quantity == null || purchasePrice == null) { | ||
| throw new IllegalArgumentException("Invalid owned share data!"); | ||
| } | ||
| this.symbol = symbol; | ||
| this.quantity = quantity; | ||
| this.purchasePrice = purchasePrice; | ||
| } | ||
|
|
||
| /** | ||
| * Getter method for the symbol. | ||
| * | ||
| * @return the stock symbol. | ||
| * */ | ||
| public String getSymbol() { | ||
| return symbol; | ||
| } | ||
|
|
||
| /** | ||
| * Getter method for the quantity. | ||
| * | ||
| * @return the quantity owned. | ||
| * */ | ||
| public BigDecimal getQuantity() { | ||
| return quantity; | ||
| } | ||
|
|
||
| /** | ||
| * Getter method for the purchase price. | ||
| * | ||
| * @return the price per unit at purchase time. | ||
| * */ | ||
| public BigDecimal getPurchasePrice() { | ||
| return purchasePrice; | ||
| } | ||
| } |
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
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
Oops, something went wrong.