From f3f95203d1ebf5a576fa6467f55d2c5e32c49656 Mon Sep 17 00:00:00 2001 From: Per Eric Trapnes Date: Fri, 15 May 2026 21:04:54 +0200 Subject: [PATCH] cleaned up the javadoc --- .../AppControllers/AppStoreController.java | 14 +-- .../AppControllers/BankAppController.java | 16 +--- .../AppControllers/SettingsAppController.java | 75 +++------------ .../AppControllers/StockAppController.java | 79 +++------------- .../gruppe42/Controller/GameController.java | 30 ++---- .../gruppe42/Controller/MarketController.java | 40 ++------ .../gruppe42/Controller/PopupsController.java | 36 ++----- .../Controller/TimeAndWeatherController.java | 61 +++--------- .../DesktopViewController.java | 89 ++++-------------- .../ViewControllers/StartViewController.java | 6 +- .../ntnu/idi/idatt2003/gruppe42/Millions.java | 38 ++------ .../idi/idatt2003/gruppe42/Model/App.java | 6 +- .../idatt2003/gruppe42/Model/Exchange.java | 80 +++------------- .../idi/idatt2003/gruppe42/Model/Player.java | 90 ++++-------------- .../idatt2003/gruppe42/Model/Portfolio.java | 45 ++------- .../idi/idatt2003/gruppe42/Model/Share.java | 48 ++-------- .../idi/idatt2003/gruppe42/Model/Stock.java | 82 +++------------- .../gruppe42/Model/StockFileHandler.java | 18 +--- .../gruppe42/Model/Transaction/Purchase.java | 15 +-- .../gruppe42/Model/Transaction/Sale.java | 15 +-- .../Model/Transaction/Transaction.java | 48 ++-------- .../Model/Transaction/TransactionArchive.java | 48 ++-------- .../idatt2003/gruppe42/View/Apps/BankApp.java | 33 ++----- .../gruppe42/View/Apps/FilePickerApp.java | 18 +--- .../gruppe42/View/Apps/GameOverApp.java | 10 +- .../gruppe42/View/Apps/HustlersApp.java | 10 +- .../idatt2003/gruppe42/View/Apps/MailApp.java | 9 +- .../idatt2003/gruppe42/View/Apps/NewsApp.java | 8 +- .../gruppe42/View/Apps/StockApp.java | 62 +++---------- .../gruppe42/View/Apps/WarningApp.java | 36 ++----- .../gruppe42/View/Apps/WeekendRapportApp.java | 19 +--- .../idi/idatt2003/gruppe42/View/Popup.java | 42 ++------- .../gruppe42/View/Views/DesktopView.java | 93 +++---------------- .../gruppe42/View/Views/StartView.java | 33 ++----- 34 files changed, 244 insertions(+), 1108 deletions(-) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java index 115e6ac..06482da 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java @@ -2,22 +2,14 @@ import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.AppStoreApp; -/** - * Controller for the App Store. - */ +/** Controller for the App Store. */ public class AppStoreController implements AppController { - /** - * Constructs a new AppStoreController. - * - * @param appStoreApp the app store view - */ + /** Constructs the controller. */ public AppStoreController(final AppStoreApp appStoreApp) { } + /** Processes next tick. */ @Override - /** - * Nexttick method. - */ public void nextTick() { } } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java index 3901ab9..1af4bc5 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java @@ -4,25 +4,15 @@ import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.BankApp; import javafx.application.Platform; -/** - * Controller for the {@link BankApp}. - * Handles updating the player's financial status and portfolio view. - */ +/** Controller for Bank app. */ public record BankAppController(BankApp bankApp, Player player) implements AppController { - /** - * Constructs a new BankAppController. - * - * @param bankApp the bank app view - * @param player the player model - */ + /** Constructs the controller. */ public BankAppController { nextTick(); } + /** Processes next tick. */ @Override - /** - * Nexttick method. - */ public void nextTick() { Platform.runLater(() -> { bankApp.updateStatus( diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/SettingsAppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/SettingsAppController.java index d78bcff..2095d41 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/SettingsAppController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/SettingsAppController.java @@ -11,9 +11,7 @@ import java.util.function.Consumer; import javafx.scene.layout.Pane; -/** - * Controller for the Settings app, handling volume changes, file picking, and profile updates. - */ +/** Controller for Settings app. */ public class SettingsAppController implements AppController { private Path userSelectedPath; @@ -28,12 +26,7 @@ public class SettingsAppController implements AppController { private final SettingsApp settingsApp; private final FilePickerApp filePickerApp; - /** - * Creates a new SettingsAppController. - * - * @param settingsApp the settings app view - * @param filePickerApp the file picker app view - */ + /** Constructs the controller. */ public SettingsAppController(final SettingsApp settingsApp, final FilePickerApp filePickerApp) { this.settingsApp = settingsApp; this.filePickerApp = filePickerApp; @@ -93,11 +86,7 @@ private void wireControls() { } } - /** - * Sets the login status of the app. - * - * @param status the new login status - */ + /** Sets the login status. */ public void setLoggedIn(final boolean status) { settingsApp.setLoggedIn(status); wireControls(); @@ -143,91 +132,53 @@ private void refreshView() { } - /** - * Sets the onuserpathselected. - * - * @param callback the new callback - */ + /** Sets onUserPathSelected callback. */ public void setOnUserPathSelected(final Runnable callback) { onUserSelection = callback; } - /** - * Sets the onselectedfilefailed. - * - * @param callback the new callback - */ + /** Sets onSelectedFileFailed callback. */ public void setOnSelectedFileFailed(final Runnable callback) { onSelectedFileFailed = callback; } - /** - * Sets the onlogout. - * - * @param callback the new callback - */ + /** Sets onLogout callback. */ public void setOnLogout(final Runnable callback) { onLogout = callback; } - /** - * Sets the onpoweroff. - * - * @param callback the new callback - */ + /** Sets onPowerOff callback. */ public void setOnPowerOff(final Runnable callback) { onPowerOff = callback; } - /** - * Sets the onplayernamechanged. - * - * @param callback the new callback - */ + /** Sets onPlayerNameChanged callback. */ public void setOnPlayerNameChanged(final Consumer callback) { onPlayerNameChanged = callback; } - /** - * Sets the ongradientchanged. - * - * @param callback the new callback - */ + /** Sets onGradientChanged callback. */ public void setOnGradientChanged(final Consumer callback) { onGradientChanged = callback; } - /** - * Returns the userselectedpath. - * - * @return the value - */ + /** @return the selected path. */ public Path getUserSelectedPath() { return userSelectedPath; } - /** - * Returns the filepickerapp. - * - * @return the value - */ + /** @return the file picker. */ public FilePickerApp getFilePickerApp() { return filePickerApp; } - /** - * Returns the errormessage. - * - * @return the value - */ + /** @return the error message. */ public String getErrorMessage() { return errorMessage; } @Override - /** - * Nexttick method. - */ + /** Processes next tick. */ public void nextTick() {} } \ No newline at end of file diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/StockAppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/StockAppController.java index bfbbf8c..32cbd72 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/StockAppController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/StockAppController.java @@ -19,11 +19,7 @@ import javafx.scene.layout.Region; import javafx.scene.layout.VBox; -/** - * Controller for the {@link StockApp}. - * Handles user interactions for buying and selling stocks, - * and updates the UI in real-time. - */ +/** Controller for StockApp. */ public final class StockAppController implements AppController { private final MarketController marketController; @@ -39,13 +35,7 @@ public final class StockAppController implements AppController { private Runnable onInsufficientFunds; - /** - * Constructs a new StockAppController. - * - * @param stockApp the stock app view - * @param marketController the market controller - * @param player the player performing transactions - */ + /** Constructs the controller. */ public StockAppController( final StockApp stockApp, final MarketController marketController, @@ -81,11 +71,7 @@ public StockAppController( stockApp.getBackButton().setOnAction(e -> navigateToSearch()); } - /** - * Navigates to the detail page for the given stock. - * - * @param stock the stock to view - */ + /** Navigates to stock detail page. */ private void navigateToStock(final Stock stock) { currentStock = stock; stock.getStockGraph().setVisibility(true); @@ -94,9 +80,7 @@ private void navigateToStock(final Stock stock) { updateReceipt(); } - /** - * Navigates back to the stock search page. - */ + /** Navigates to search page. */ private void navigateToSearch() { if (currentStock != null) { currentStock.getStockGraph().setVisibility(false); @@ -105,11 +89,7 @@ private void navigateToSearch() { stockApp.showSearchPage(); } - /** - * Creates a list cell for displaying a stock row. - * - * @return a configured list cell - */ + /** Creates list cell for stock row. */ private ListCell createStockCell() { return new ListCell<>() { private final HBox row = new HBox(15); @@ -171,13 +151,7 @@ protected void updateItem(final Stock stock, final boolean empty) { }; } - /** - * Enables or disables trading based on whether it is a weekend. - * When weekend is {@code true} the Trade button is visually dimmed and - * the spinner is disabled; clicking Trade triggers the market-closed callback. - * - * @param weekend {@code true} on Saturday/Sunday, {@code false} on weekdays - */ + /** Sets weekend status. */ public void setWeekend(final boolean weekend) { this.isWeekend = weekend; Button tradeButton = stockApp.getConfirmButton(); @@ -192,27 +166,17 @@ public void setWeekend(final boolean weekend) { } } - /** - * Registers the callback invoked when the player clicks Trade on a weekend. - * - * @param callback the action to run (typically shows a market-closed warning) - */ + /** Sets market closed callback. */ public void setOnMarketClosed(final Runnable callback) { this.onMarketClosed = callback; } - /** - * Registers the callback invoked when the player has insufficient funds. - * - * @param callback the action to run (typically shows an insufficient-funds warning) - */ + /** Sets insufficient funds callback. */ public void setOnInsufficientFunds(final Runnable callback) { this.onInsufficientFunds = callback; } - /** - * Handles the trade button action based on the spinner value. - */ + /** Handles trade button action. */ private void handleTransaction() { if (isWeekend) { if (onMarketClosed != null) { @@ -239,12 +203,7 @@ private void handleTransaction() { } } - /** - * Performs a buy transaction for the given stock. - * - * @param stock the stock to buy - * @param quantity the quantity to buy - */ + /** Buys given stock. */ private void handleBuy(final Stock stock, final BigDecimal quantity) throws Exception { Transaction transaction = marketController.getExchange() .buy(stock.getSymbol(), quantity); @@ -254,12 +213,7 @@ private void handleBuy(final Stock stock, final BigDecimal quantity) throws Exce } } - /** - * Performs a sell transaction for the given stock. - * - * @param stock the stock to sell - * @param quantity the quantity to sell - */ + /** Sells given stock. */ private void handleSell(final Stock stock, final BigDecimal quantity) { player.getPortfolio().getShares().stream() .filter(share -> share.getStock().getSymbol().equals(stock.getSymbol())) @@ -282,9 +236,7 @@ private void handleSell(final Stock stock, final BigDecimal quantity) { }); } - /** - * Updates the receipt display based on the current stock and spinner value. - */ + /** Updates receipt view. */ private void updateReceipt() { if (currentStock != null) { Platform.runLater(() -> @@ -296,13 +248,8 @@ private void updateReceipt() { } } - /** - * Updates the app state on each simulation tick. - */ + /** Processes next tick. */ @Override - /** - * Nexttick method. - */ public void nextTick() { marketController.updateMarket(); Platform.runLater(() -> stockApp.getStockList().refresh()); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java index 8f9ba2d..2edd7e0 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java @@ -9,9 +9,7 @@ import java.util.Timer; import java.util.TimerTask; -/** - * Represents a GameController class. - */ +/** Controller for the main game loop. */ public final class GameController { private final List appControllers = new ArrayList<>(); @@ -21,18 +19,12 @@ public final class GameController { private boolean workMusicPlaying = false; private boolean weekendMusicPlaying = false; - /** - * Addappcontroller method. - */ + /** Adds an app controller. */ public void addAppController(final AppController appController) { appControllers.add(appController); } - /** - * Sets the game state and handles music transitions. - * - * @param gameState the new game state - */ + /** Sets the game state. */ public void setGameState(final GameState gameState) { this.gameState = gameState; @@ -49,19 +41,15 @@ public void setGameState(final GameState gameState) { } } - /** - * Startgame method. - */ + /** Starts the game loop. */ public void startGame() { timer = new Timer(true); final int delay = 0; final int period = 1000; timer.scheduleAtFixedRate(new TimerTask() { + /** Processes game tick. */ @Override - /** - * Run method. - */ public void run() { for (AppController controller : appControllers) { controller.nextTick(); @@ -73,9 +61,7 @@ public void run() { }, delay, period); } - /** - * Stopgame method. - */ + /** Stops the game loop. */ public void stopGame() { if (timer != null) { timer.cancel(); @@ -83,9 +69,7 @@ public void stopGame() { } } - /** - * Isweekend method. - */ + /** @return true if weekend. */ public boolean isWeekend() { return gameState != GameState.WORKDAY; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java index 2ff6f1a..09bbbd1 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java @@ -11,17 +11,12 @@ import java.util.List; import java.util.Objects; -/** - * Controller for the stock market. - * Manages the exchange and updates stock prices. - */ +/** Controller for the stock market. */ public final class MarketController { private Exchange exchange; private final int stockResolution; - /** - * Constructs a new MarketController and starts the market. - */ + /** Constructs and starts the market. */ public MarketController(Path path) { this.stockResolution = 120; try { @@ -35,28 +30,17 @@ public MarketController(Path path) { } } - /** - * Returns the exchange. - * - * @return the value - */ + /** @return the exchange. */ public Exchange getExchange() { return exchange; } - /** - * Searches for stocks matching a search term. - * - * @param searchTerm the term to search for - * @return a list of matching stocks - */ + /** Searches for matching stocks. */ public List getMarket(final String searchTerm) { return exchange.findStocks(searchTerm); } - /** - * Updates the market by updating all stock prices and graphs. - */ + /** Updates stock prices and graphs. */ public void updateMarket() { for (Stock stock : exchange.getAllStocks()) { stock.updatePrice(); @@ -64,9 +48,7 @@ public void updateMarket() { } } - /** - * Starts the market by performing initial updates. - */ + /** Performs initial updates. */ public void startMarket() { for (Stock stock : exchange.getAllStocks()) { stock.fakeHistory(stockResolution); @@ -75,20 +57,14 @@ public void startMarket() { } } - /** - * Prints the market history to console. - * - * @param stocks the list of stocks to print - */ + /** Prints market history. */ public static void printMarket(final List stocks) { for (Stock stock : stocks) { System.out.println(stock.getHistoricalPrices().toString()); } } - /** - * Advanceweek method. - */ + /** Advances the week. */ public void advanceWeek() { exchange.advance(); } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java index 523d8f3..292d091 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java @@ -11,9 +11,7 @@ import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; -/** - * Manages popup visibility, dragging, and bounds-clamping. - */ +/** Manages popup behavior. */ public final class PopupsController { private final List popups; @@ -29,9 +27,7 @@ private void initPopup(Popup popup) { popup.getCloseButton().setOnAction(event -> hide(popup.getType())); } - /** - * Show method. - */ + /** Shows a popup. */ public boolean show(App type) { if (type == null) { return false; @@ -44,9 +40,7 @@ public boolean show(App type) { return true; } - /** - * Hide method. - */ + /** Hides a popup. */ public boolean hide(App type) { if (type == null) { return false; @@ -59,9 +53,7 @@ public boolean hide(App type) { return true; } - /** - * Bindopenbutton method. - */ + /** Binds button to show popup. */ public void bindOpenButton(Button button, App type) { button.setOnAction(event -> show(type)); } @@ -86,36 +78,24 @@ private void makeDraggable(Popup popup) { }); } - /** - * Addpopups method. - */ + /** Adds popups. */ public void addPopups(List popups) { popups.forEach(this::addPopup); } - /** - * Addpopup method. - */ + /** Adds a popup. */ public void addPopup(Popup popup) { initPopup(popup); this.popups.add(popup); } - /** - * Returns the popup. - * - * @return the value - */ + /** @return the popup. */ public Popup getPopup(App type) { Optional match = popups.stream().filter(popup -> popup.getType().equals(type)).findFirst(); return match.orElse(null); } - /** - * Returns the popups. - * - * @return the value - */ + /** @return the popups. */ public List getPopups() { return popups; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/TimeAndWeatherController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/TimeAndWeatherController.java index 2cfe15a..2499382 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/TimeAndWeatherController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/TimeAndWeatherController.java @@ -13,10 +13,7 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; -/** - * Controller for managing game time and weather. - * Advances 1 hour per tick. - */ +/** Manages game time and weather. */ public class TimeAndWeatherController implements AppController { private final IntegerProperty hour = new SimpleIntegerProperty(0); private final IntegerProperty dayIndex = new SimpleIntegerProperty(0); @@ -35,10 +32,8 @@ public TimeAndWeatherController(GameController gameController) { updateGameState(); } + /** Processes next tick. */ @Override - /** - * Nexttick method. - */ public void nextTick() { int nextHour = hour.get() + 1; if (nextHour >= 24) { @@ -70,30 +65,22 @@ private void updateWeather() { } } - /** - * Hourproperty method. - */ + /** @return hour property. */ public IntegerProperty hourProperty() { return hour; } - /** - * Dayindexproperty method. - */ + /** @return day index property. */ public IntegerProperty dayIndexProperty() { return dayIndex; } - /** - * Weekindexproperty method. - */ + /** @return week index property. */ public IntegerProperty weekIndexProperty() { return weekNumber; } - /** - * Advanceweek method. - */ + /** Advances the week. */ public void advanceWeek() { weekNumber.set(weekNumber.get() + 1); dayIndex.set(1); @@ -101,50 +88,32 @@ public void advanceWeek() { gameController.startGame(); } - /** - * Temperatureproperty method. - */ + /** @return temperature property. */ public IntegerProperty temperatureProperty() { return temperature; } - /** - * Weatherproperty method. - */ + /** @return weather property. */ public StringProperty weatherProperty() { return weather; } - /** - * Returns the timestring. - * - * @return the value - */ + /** @return time string. */ public String getTimeString() { return String.format("%02d:00", hour.get()); } - /** - * Returns the dayofweekstring. - * - * @return the value - */ + /** @return day of week string. */ public String getDayOfWeekString() { return DAYS[dayIndex.get()].toString(); } - /** - * Returns the weekstring. - * - * @return the value - */ + /** @return week string. */ public String getWeekString() { return "Week " + weekNumber.get(); } - /** - * Updategamestate method. - */ + /** Updates game state. */ public void updateGameState() { if (dayIndex.get() == 6) { gameController.setGameState(GameState.RENTDAY); @@ -156,11 +125,7 @@ public void updateGameState() { gameController.setGameState(GameState.WORKDAY); } - /** - * Sets the day. - * - * @param value the new value - */ + /** Sets the day. */ public void setDay(int index) { dayIndex.set(index); updateGameState(); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java index f52e0c4..c51015b 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java @@ -43,9 +43,7 @@ import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; -/** - * Controller for the desktop view, handling week advancement, app opening, and UI updates. - */ +/** Controller for the desktop view. */ public final class DesktopViewController { private static final BigDecimal WEEKLY_RENT = new BigDecimal("50.00"); @@ -65,14 +63,7 @@ public final class DesktopViewController { private DesktopView desktopView = null; private Runnable onGameOver; - /** - * Creates a new DesktopViewController. - * - * @param player the player model - * @param gameController the main game controller - * @param userSelectedPath the path to the stock file - * @param popupsController the controller for popups - */ + /** Constructs the controller. */ public DesktopViewController( final Player player, final GameController gameController, @@ -259,9 +250,7 @@ private void doAdvanceWeek() { } - /** - * Shows a warning when the player is in debt. - */ + /** Shows debt warning. */ private void showDebtWarning() { warningApp.configure( "💔", @@ -283,9 +272,7 @@ private void showDebtWarning() { showWarning(); } - /** - * Shows a warning when the market is closed. - */ + /** Shows market closed warning. */ private void showMarketClosedWarning() { warningApp.configure( "🔒", @@ -297,9 +284,7 @@ private void showMarketClosedWarning() { showWarning(); } - /** - * Shows a warning when the player has insufficient funds. - */ + /** Shows insufficient funds warning. */ private void showInsufficientFundsWarning() { warningApp.configure( "\uD83E\uDD7A", @@ -311,64 +296,45 @@ private void showInsufficientFundsWarning() { showWarning(); } - /** - * Displays the warning modal. - */ + /** Displays warning modal. */ private void showWarning() { warningApp.show(); desktopView.enterLayer(ModalLayer.WARNING); } - /** - * Dismisses the current warning modal. - */ + /** Dismisses the warning. */ private void dismissWarning() { warningApp.getRoot().setVisible(false); desktopView.exitLayer(ModalLayer.WARNING); } - /** - * Shows the game over screen. - */ + /** Shows the game over screen. */ private void showGameOver() { gameOverApp.show(); desktopView.enterLayer(ModalLayer.GAME_OVER); } - /** - * Wires the game over buttons. - */ + /** Wires game over buttons. */ private void wireGameOver() { gameOverApp.getStartOverButton().setOnAction(event -> { if (onGameOver != null) onGameOver.run(); }); } - /** - * Sets the callback for when the game is over. - * - * @param callback the callback to run - */ + /** Sets the game over callback. */ public void setOnGameOver(final Runnable callback) { this.onGameOver = callback; } - /** - * Handles the logout action. - */ + /** Handles logout action. */ private void handleLogout() { if (onGameOver != null) onGameOver.run(); } - /** - * Creates an app button for the given app type. - * - * @param type the app type - * @return the created Button - */ + /** Creates an app button. */ public Button createAppButton(final App type) { Button button = new Button(type.getDisplayName()); button.getStyleClass().add("app-button"); @@ -407,11 +373,7 @@ public Button createAppButton(final App type) { return button; } - /** - * Configures a StackPane as a drop target for app buttons. - * - * @param cell the StackPane to configure - */ + /** Configures StackPane as drop target. */ public void configureCellAsDropTarget(final StackPane cell) { cell.setOnDragOver(event -> { if (event.getGestureSource() instanceof Button && cell.getChildren().isEmpty()) { @@ -433,40 +395,23 @@ public void configureCellAsDropTarget(final StackPane cell) { } - /** - * Returns the player model. - * - * @return the Player - */ + /** @return the player model. */ public Player getPlayer() { return player; } - /** - * Returns the time and weather controller. - * - * @return the TimeAndWeatherController - */ + /** @return the time/weather controller. */ public TimeAndWeatherController getTimeAndWeatherController() { return timeAndWeatherController; } - /** - * Returns the desktop view. - * - * @return the DesktopView - */ + /** @return the desktop view. */ public DesktopView getDesktopView() { return desktopView; } - /** - * Calculates the net income for a list of transactions. - * - * @param transactions the list of transactions - * @return the net income - */ + /** Calculates net income. */ private static BigDecimal calculateNetIncome(final List transactions) { BigDecimal net = BigDecimal.ZERO; for (Transaction t : transactions) { diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/StartViewController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/StartViewController.java index 36d1695..c01562a 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/StartViewController.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/StartViewController.java @@ -17,11 +17,7 @@ import java.util.Objects; import java.util.Random; -/** - * Controller for the start / login screen. - * Validates user input and delegates to {@link Millions#initGame} on success. - * Uses the shared {@link WarningApp} popup for validation feedback. - */ +/** Controller for the start screen. */ public class StartViewController { private String username = ""; diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java index 16b6e83..1a082e8 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java @@ -15,15 +15,7 @@ import java.nio.file.Path; -/** - * JavaFX application entry point. - * - *

Owns the lifecycle of every game instance: a brand-new {@link Player}, - * {@link GameController}, {@link DesktopView}, and {@link DesktopViewController} - * is created per game session. {@link #resetGame()} is the one place that - * tears down a session and returns to a fresh start screen so no stale - * state ever survives.

- */ +/** JavaFX application entry point. */ public class Millions extends Application { private Scene scene; @@ -34,10 +26,8 @@ public class Millions extends Application { private DesktopView desktopView; private DesktopViewController desktopViewController; + /** Start method. */ @Override - /** - * Start method. - */ public void start(final Stage stage) { StartView startView = installStartView(); scene = new Scene(startView.getRoot(), 900, 700); @@ -49,10 +39,7 @@ public void start(final Stage stage) { stage.show(); } - /** - * Begins a brand-new game session. Called by the start screen once the - * user has chosen a difficulty. - */ + /** Begins a new game session. */ public void initGame(final String username, final Difficulty difficulty, Path userSelectedPath, PopupsController popupsController) { player = GameFactory.createPlayer(username, difficulty); gameController = new GameController(); @@ -64,14 +51,7 @@ public void initGame(final String username, final Difficulty difficulty, Path us scene.setRoot(desktopView.getRoot()); } - /** - * Single, centralised teardown / reset path. - * - *

Stops the running game, drops every reference to the previous - * session's state (player, lives, cash, transactions, popups, …) and - * builds a fresh start screen with a fresh controller. After this - * call the app behaves exactly as if it had just launched.

- */ + /** Centralised reset path. */ public void resetGame() { if (gameController != null) { gameController.stopGame(); @@ -85,21 +65,15 @@ public void resetGame() { scene.setRoot(startView.getRoot()); } - /** - * Builds a fresh {@link StartView} and binds a fresh - * {@link StartViewController} to it. Used by both the initial launch - * and {@link #resetGame()}. - */ + /** Builds a fresh StartView. */ private StartView installStartView() { StartView startView = new StartView(); new StartViewController(this, startView); return startView; } + /** Stop method. */ @Override - /** - * Stop method. - */ public void stop() { if (gameController != null) { gameController.stopGame(); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/App.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/App.java index e44e916..b261d05 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/App.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/App.java @@ -1,8 +1,6 @@ package edu.ntnu.idi.idatt2003.gruppe42.Model; -/** - * Enumeration of available applications in the simulation. - */ +/** Apps in the simulation. */ public enum App { APPSTORE("App Store"), HUSTLERS("Hustlers"), @@ -22,7 +20,7 @@ public enum App { this.displayName = displayName; } - /** Title used in popup headers and button labels. */ + /** @return the display name. */ public String getDisplayName() { return displayName; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exchange.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exchange.java index f703b3d..e4b3d60 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exchange.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exchange.java @@ -10,13 +10,7 @@ import java.util.List; import java.util.Map; -/** - * Represents a stock exchange where players can buy and sell shares. - *

- * The {@code Exchange} keeps track of available stocks, the current week in the simulation, - * and allows players to perform transactions such as buying or selling shares. - *

- */ +/** Represents a stock exchange. */ public class Exchange { /** The current week in the simulation. */ private int week; @@ -24,11 +18,7 @@ public class Exchange { private final Map stockMap; - /** - * Constructs a new {@code Exchange} with a list of stocks. - * - * @param stocks the initial list of available stocks - */ + /** Constructs the exchange. */ public Exchange(final List stocks) { this.week = 0; this.stockMap = new HashMap(); @@ -37,41 +27,22 @@ public Exchange(final List stocks) { } } - /** - * Returns the current week in the simulation. - * - * @return the week - */ + /** @return the current week. */ public int getWeek() { return week; } - /** - * Checks if the exchange has a stock with the given symbol. - * - * @param symbol the stock symbol to check - * @return {@code true} if found - */ + /** @return true if exchange has stock. */ public boolean hasStock(final String symbol) { return stockMap.containsKey(symbol); } - /** - * Returns the stock associated with the given symbol. - * - * @param symbol the symbol of the stock to retrieve - * @return the {@code Stock} object, or {@code null} if not found - */ + /** @return the stock for given symbol. */ public Stock getStock(final String symbol) { return stockMap.get(symbol); } - /** - * Finds stocks by company name. - * - * @param searchTerm the company name to search for - * @return a list of matching stocks - */ + /** @return matching stocks. */ public List findStocks(final String searchTerm) { List foundStocks = new ArrayList<>(); String lowerSearchTerm = searchTerm.toLowerCase(); @@ -85,22 +56,12 @@ public List findStocks(final String searchTerm) { return foundStocks; } - /** - * Returns all available stocks. - * - * @return a list of all stocks - */ + /** @return all stocks. */ public List getAllStocks() { return new ArrayList<>(stockMap.values()); } - /** - * Allows a player to buy a stock from the exchange. - * - * @param symbol the symbol of the stock to buy - * @param quantity the amount of stock to buy - * @return a {@code Purchase} transaction - */ + /** @return purchase transaction. */ public Transaction buy( final String symbol, final BigDecimal quantity @@ -112,14 +73,7 @@ public Transaction buy( return new Purchase(share, week); } - /** - * Allows a player to sell a share on the exchange. - * - * @param share the share position to sell from - * @param quantity the amount to sell - * @param player the player performing the sale - * @return a {@code Sale} transaction - */ + /** @return sale transaction. */ public Transaction sell( final Share share, final BigDecimal quantity, @@ -131,18 +85,12 @@ public Transaction sell( return new Sale(shareToSell, week); } - /** - * Advances the simulation by 1 week. - */ + /** Advances simulation by one week. */ public void advance() { week += 1; } - /** - * Returns the top stocks by price change given a limit. - * - * @return a list of gainer stocks - */ + /** @return stocks by gain. */ public List getGainers() { return stockMap.values().stream() .sorted((a, b) -> b.getLatestPriceChange() @@ -150,11 +98,7 @@ public List getGainers() { .toList(); } - /** - * Returns the bottom stocks by price change given a limit. - * - * @return a list of loser stocks - */ + /** @return stocks by loss. */ public List getLosers() { return stockMap.values().stream() .sorted(Comparator.comparing(Stock::getLatestPriceChange)) diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java index 9c1779f..668dd62 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java @@ -8,9 +8,7 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; -/** - * A player in the Millions game, tracks money, lives, and portfolio. - */ +/** Represents a player. */ public class Player { private static final int MAX_LIVES = 3; @@ -31,60 +29,36 @@ public Player(final String name, final BigDecimal startingMoney) { } - /** - * Returns the name property. - * - * @return the name property - */ + /** @return name property. */ public StringProperty getNameProperty() { return name; } - /** - * Returns the player's name. - * - * @return the name - */ + /** @return player's name. */ public String getName() { return name.get(); } - /** - * Sets the player's name. - * - * @param name the new name - */ + /** Sets player's name. */ public void setName(final String name) { this.name.set(name); } - /** - * Returns the starting money. - * - * @return the starting money - */ + /** @return starting money. */ public BigDecimal getStartingMoney() { return startingMoney; } - /** - * Returns the current money. - * - * @return the current money - */ + /** @return current money. */ public BigDecimal getMoney() { return money; } - /** - * Addmoney method. - */ + /** Adds money. */ public void addMoney(final BigDecimal amount) { money = money.add(amount); } - /** - * Withdrawmoney method. - */ + /** Withdraws money. */ public void withdrawMoney(final BigDecimal amount) throws InsufficientFunds { if (money.compareTo(amount) < 0) { throw new InsufficientFunds("Not enough money to withdraw " + amount); @@ -92,80 +66,50 @@ public void withdrawMoney(final BigDecimal amount) throws InsufficientFunds { money = money.subtract(amount); } - /** - * Deductrent method. - */ + /** Deducts rent. */ public void deductRent(final BigDecimal amount) { money = money.subtract(amount); } - /** - * Isindebt method. - */ + /** @return true if in debt. */ public boolean isInDebt() { return money.compareTo(BigDecimal.ZERO) < 0; } - /** - * Returns the networth. - * - * @return the value - */ + /** @return total net worth. */ public BigDecimal getNetWorth() { return money.add(portfolio.getNetWorth()); } - /** - * Returns the lives property. - * - * @return the lives property - */ + /** @return lives property. */ public IntegerProperty getLivesProperty() { return lives; } - /** - * Returns the number of lives. - * - * @return the number of lives - */ + /** @return number of lives. */ public int getLives() { return lives.get(); } - /** - * Loselife method. - */ + /** Decrements life. */ public void loseLife() { lives.set(Math.max(0, lives.get() - 1)); } - /** - * Returns the portfolio. - * - * @return the portfolio - */ + /** @return player's portfolio. */ public Portfolio getPortfolio() { return portfolio; } - /** - * Returns the transaction archive. - * - * @return the transaction archive - */ + /** @return transaction archive. */ public TransactionArchive getTransactionArchive() { return transactionArchive; } - /** - * Returns the status. - * - * @return the value - */ + /** @return player status. */ public Status getStatus() { final int investorWeeks = 10; final int speculatorWeeks = 20; diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java index b759c30..ec2cb39 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java @@ -9,29 +9,16 @@ import java.util.List; import java.util.Optional; -/** - * Represents a collection of {@link Share} objects owned by a {@link Player}. - *

- * A {@code Portfolio} allows adding, removing, and querying shares. - * It serves as the player's collection of owned shares. - *

- */ +/** Represents a player's portfolio. */ public class Portfolio { private final List shares; - /** - * Constructs an empty {@code Portfolio}. - */ + /** Constructs an empty portfolio. */ public Portfolio() { this.shares = new ArrayList<>(); } - /** - * Adds a share to the portfolio. - * - * @param share the {@code Share} to add - * @return {@code true} if the share was successfully added - */ + /** Adds a share. */ public boolean addShare(final Share share) { if (share == null) { return false; @@ -64,12 +51,7 @@ public boolean addShare(final Share share) { return shares.add(share); } - /** - * Removes a share from the portfolio. - * - * @param newShare the {@code Share} to remove - * @return {@code true} if the share was successfully removed - */ + /** Removes a share. */ public boolean removeShare(final Share newShare) { if (newShare == null) { return false; @@ -106,30 +88,17 @@ public boolean removeShare(final Share newShare) { } } - /** - * Returns the shares. - * - * @return the value - */ + /** @return list of shares. */ public List getShares() { return shares; } - /** - * Checks whether the portfolio contains a given share. - * - * @param share the {@code Share} to check for - * @return {@code true} if found - */ + /** @return true if portfolio contains share. */ public boolean contains(final Share share) { return share != null && shares.contains(share); } - /** - * Calculates the total net worth of all shares if sold today. - * - * @return the total net worth - */ + /** @return total net worth of shares. */ public BigDecimal getNetWorth() { BigDecimal totalSum = BigDecimal.ZERO; for (Share share : shares) { diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Share.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Share.java index a080860..6fd48b9 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Share.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Share.java @@ -3,25 +3,13 @@ import java.math.BigDecimal; import java.util.Objects; -/** - * Represents a share of a particular stock owned by a player. - *

- * A {@code Share} keeps track of the stock it represents, the quantity owned, - * and the purchase price at which it was bought. - *

- */ +/** Represents owned shares. */ public class Share { private final Stock stock; private BigDecimal quantity; private final BigDecimal purchasePrice; - /** - * Constructs a new {@code Share} with stock, quantity, and purchase price. - * - * @param stock the stock that this share represents - * @param quantity the number of shares owned - * @param purchasePrice the price per share at the time of purchase - */ + /** Constructs a new share. */ public Share( final Stock stock, final BigDecimal quantity, @@ -32,46 +20,28 @@ public Share( this.purchasePrice = purchasePrice; } - /** - * Returns the stock this share represents. - * - * @return the stock - */ + /** @return the stock. */ public Stock getStock() { return stock; } - /** - * Sets the quantity of shares owned. - * - * @param quantity the new quantity - */ + /** Sets quantity. */ public void setQuantity(final BigDecimal quantity) { this.quantity = quantity; } - /** - * Returns the quantity of shares owned. - * - * @return the quantity - */ + /** @return quantity. */ public BigDecimal getQuantity() { return quantity; } - /** - * Returns the purchase price per share. - * - * @return the purchase price - */ + /** @return purchase price. */ public BigDecimal getPurchasePrice() { return purchasePrice; } + /** Equals method. */ @Override - /** - * Equals method. - */ public boolean equals(Object object) { if (this == object) { return true; @@ -85,10 +55,8 @@ public boolean equals(Object object) { && (purchasePrice == null ? share.purchasePrice == null : purchasePrice.compareTo(share.purchasePrice) == 0); } + /** HashCode method. */ @Override - /** - * Hashcode method. - */ public int hashCode() { return Objects.hash(stock.getSymbol(), quantity, purchasePrice); } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java index 243d0bc..fcc8c7a 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java @@ -5,26 +5,14 @@ import java.util.ArrayList; import java.util.List; -/** - * Represents a stock of a company in the {@link Exchange}. - *

- * Each stock has a unique symbol, a company name, and a history of sales prices. - * You can retrieve the current price or add new prices as the market changes. - *

- */ +/** Represents a stock of a company. */ public class Stock { private final String symbol; private final String company; private StockGraph stockGraph; private List prices = new ArrayList<>(); - /** - * Constructs a new stock with symbol, company name, and initial sales price. - * - * @param symbol the unique stock symbol (e.g., "AAPL") - * @param company the company name (e.g., "Apple Inc.") - * @param salesPrice the initial sales price of the stock - */ + /** Constructs a new stock. */ public Stock( final String symbol, final String company, @@ -35,74 +23,42 @@ public Stock( prices.add(salesPrice); } - /** - * Returns the symbol. - * - * @return the value - */ + /** @return the symbol. */ public String getSymbol() { return symbol; } - /** - * Returns the company. - * - * @return the value - */ + /** @return the company. */ public String getCompany() { return company; } - /** - * Returns the current sales price of the stock. - * - * @return the current price - */ + /** @return current sales price. */ public BigDecimal getSalesPrice() { return prices.isEmpty() ? BigDecimal.ZERO : prices.get(prices.size() - 1); } - /** - * Adds a new sales price to the stock's price history. - * - * @param salesPrice the new sales price to add - */ + /** Adds a new sales price. */ public void addNewSalesPrice(final BigDecimal salesPrice) { prices.add(salesPrice); } - /** - * Returns a list of historical prices. - * - * @return a list of prices - */ + /** @return historical prices. */ public List getHistoricalPrices() { return List.copyOf(prices); } - /** - * Returns the highest price in the stock's history. - * - * @return the highest price - */ + /** @return highest price. */ public BigDecimal getHighestPrice() { return prices.stream().max(BigDecimal::compareTo).orElse(BigDecimal.ZERO); } - /** - * Returns the lowest price in the stock's history. - * - * @return the lowest price - */ + /** @return lowest price. */ public BigDecimal getLowestPrice() { return prices.stream().min(BigDecimal::compareTo).orElse(BigDecimal.ZERO); } - /** - * Returns the difference between the current and previous price. - * - * @return the price change - */ + /** @return price change. */ public BigDecimal getLatestPriceChange() { final int minSize = 2; if (prices.size() < minSize) { @@ -112,9 +68,7 @@ public BigDecimal getLatestPriceChange() { .subtract(prices.get(prices.size() - 2)); } - /** - * Simulates a price update. - */ + /** Updates the price. */ public void updatePrice() { BigDecimal oldPrice = getSalesPrice(); BigDecimal newPrice = oldPrice.add(new BigDecimal("1")); @@ -122,11 +76,7 @@ public void updatePrice() { prices.add(newPrice); } - /** - * Returns the stock graph component, initializing it if necessary. - * - * @return the stock graph - */ + /** @return stock graph. */ public StockGraph getStockGraph() { if (stockGraph == null) { stockGraph = new StockGraph(); @@ -134,9 +84,7 @@ public StockGraph getStockGraph() { return stockGraph; } - /** - * Fakehistory method. - */ + /** Generates fake history. */ public void fakeHistory(int stockResolution) { for (int i = 0; i < stockResolution; i++) { updatePrice(); @@ -144,9 +92,7 @@ public void fakeHistory(int stockResolution) { java.util.Collections.reverse(prices); } - /** - * Updates the stock graph if it is visible. - */ + /** Updates the stock graph. */ public void updateStockGraph() { if (stockGraph != null && stockGraph.getVisibility()) { stockGraph.update(this); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandler.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandler.java index 6a062cf..f616718 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandler.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandler.java @@ -13,29 +13,17 @@ import java.util.List; import java.util.regex.Pattern; -/** - * Utility class for handling file data. - * Includes methods for reading and writing from file. - */ +/** Utility for handling stock file data. */ public final class StockFileHandler { private static final Pattern SYMBOL_PATTERN = Pattern.compile("^[A-Z.]{1,5}$"); private static final Pattern PRICE_PATTERN = Pattern.compile("^\\d+\\.\\d{2}$"); private static final int EXPECTED_FIELDS = 3; - /** - * Private constructor to prevent instantiation. - */ + /** Private constructor. */ private StockFileHandler() { } - /** - * Method for parsing stock data into stock objects. - * - * @param path the path of the file being parsed - * @return list of stock objects - * @throws IOException if file not found or error occurs - */ - + /** Parses stock data from file. */ public static List readFromFile(final Path path) throws IOException, StockFileParseException { diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java index 5500768..84c6151 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java @@ -7,24 +7,15 @@ import java.math.BigDecimal; -/** - * Represents a stock purchase transaction. - */ +/** Represents a stock purchase. */ public final class Purchase extends Transaction { - /** - * Constructs a new Purchase transaction. - * - * @param share the share position being bought - * @param week the simulation week - */ + /** Constructs a purchase. */ public Purchase(final Share share, final int week) { super(share, week, new PurchaseCalculator(share)); } + /** Commits the purchase. */ @Override - /** - * Commit method. - */ public void commit(final Player player) throws Exception { setCommitted(true); player.withdrawMoney(getCalculator().calculateTotal()); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.java index 7383179..55c0c4c 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.java @@ -4,24 +4,15 @@ import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; import edu.ntnu.idi.idatt2003.gruppe42.Model.Share; -/** - * Represents a stock sale transaction. - */ +/** Represents a stock sale. */ public final class Sale extends Transaction { - /** - * Constructs a new Sale transaction. - * - * @param share the share position being sold - * @param week the simulation week - */ + /** Constructs a sale. */ public Sale(final Share share, final int week) { super(share, week, new SaleCalculator(share)); } + /** Commits the sale. */ @Override - /** - * Commit method. - */ public void commit(final Player player) { setCommitted(true); player.addMoney(getCalculator().calculateTotal()); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.java index c843781..f5024e4 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.java @@ -4,22 +4,14 @@ import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; import edu.ntnu.idi.idatt2003.gruppe42.Model.Share; -/** - * Abstract base class for financial transactions. - */ +/** Base class for transactions. */ public abstract class Transaction { private final Share share; private final int week; private final TransactionCalculator calculator; private boolean committed = false; - /** - * Constructs a new Transaction. - * - * @param share the share position - * @param week the simulation week - * @param calculator the cost calculator - */ + /** Constructs a new transaction. */ protected Transaction( final Share share, final int week, @@ -31,54 +23,30 @@ protected Transaction( this.committed = false; } - /** - * Returns the share position. - * - * @return the share - */ + /** @return the share. */ public Share getShare() { return share; } - /** - * Returns the week of the transaction. - * - * @return the week - */ + /** @return the week. */ public int getWeek() { return week; } - /** - * Returns the calculator used. - * - * @return the calculator - */ + /** @return the calculator. */ public TransactionCalculator getCalculator() { return calculator; } - /** - * Returns whether the transaction is committed. - * - * @return true if committed - */ + /** @return true if committed. */ public boolean isCommitted() { return committed; } - /** - * Commits the transaction for a player. - * - * @param player the player performing the transaction - */ + /** Commits the transaction. */ public abstract void commit(Player player) throws Exception; - /** - * Sets the committed status of the transaction. - * - * @param committed the new status - */ + /** Sets committed status. */ public void setCommitted(final boolean committed) { this.committed = committed; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.java index 250ef1f..be40af8 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.java @@ -5,26 +5,17 @@ import java.util.List; import java.util.Set; -/** - * Archive for storing and querying past transactions. - */ +/** Archive for past transactions. */ public final class TransactionArchive { /** The list of stored transactions. */ private final List transactions; - /** - * Constructs an empty TransactionArchive. - */ + /** Constructs an empty archive. */ public TransactionArchive() { this.transactions = new ArrayList<>(); } - /** - * Adds a transaction to the archive. - * - * @param transaction the transaction to add - * @return true if added - */ + /** Adds a transaction. */ public boolean add(final Transaction transaction) { if (transaction == null) { return false; @@ -33,21 +24,12 @@ public boolean add(final Transaction transaction) { } } - /** - * Checks if the archive is empty. - * - * @return true if empty - */ + /** @return true if empty. */ public boolean isEmpty() { return transactions.isEmpty(); } - /** - * Returns all transactions that occurred in a specific week. - * - * @param week the simulation week - * @return a list of transactions - */ + /** @return transactions for given week. */ public List getTransactions(final int week) { List transactionsThisWeek = new ArrayList<>(); @@ -60,12 +42,7 @@ public List getTransactions(final int week) { return transactionsThisWeek; } - /** - * Returns all purchase transactions that occurred in a specific week. - * - * @param week the simulation week - * @return a list of purchases - */ + /** @return purchases for given week. */ public List getPurchases(final int week) { List purchasesThisWeek = new ArrayList<>(); @@ -78,12 +55,7 @@ public List getPurchases(final int week) { return purchasesThisWeek; } - /** - * Returns all sale transactions that occurred in a specific week. - * - * @param week the simulation week - * @return a list of sales - */ + /** @return sales for given week. */ public List getSales(final int week) { List salesThisWeek = new ArrayList<>(); @@ -96,11 +68,7 @@ public List getSales(final int week) { return salesThisWeek; } - /** - * Counts the number of distinct weeks in which transactions occurred. - * - * @return the number of distinct weeks - */ + /** @return distinct weeks count. */ public int countDistinctWeeks() { Set distinctWeeks = new HashSet<>(); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/BankApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/BankApp.java index 8b8ae9f..e394537 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/BankApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/BankApp.java @@ -19,9 +19,7 @@ import javafx.scene.layout.VBox; import javafx.scene.paint.Color; -/** - * Bank app popup showing portfolio summary and individual share holdings. - */ +/** Bank app popup showing portfolio summary. */ public class BankApp extends Popup { private static final String POSITIVE_STYLE = "stock-price-positive"; @@ -35,9 +33,7 @@ public class BankApp extends Popup { private Consumer onShareSelected; - /** - * Constructs the Bank app popup. - */ + /** Constructs the Bank app. */ public BankApp() { super(500, 550, 220, 100, App.BANK); @@ -127,14 +123,7 @@ private VBox summaryItem(String title, Label valueLabel) { return box; } - /** - * Refreshes the summary labels with the latest financial figures. - * - * @param netWorth total net worth (cash + portfolio value) - * @param cash uninvested cash available - * @param invested current market value of shares held - * @param startingMoney initial balance used as the growth baseline - */ + /** Refreshes summary with latest figures. */ public void updateStatus(double netWorth, double cash, double invested, double startingMoney) { Platform.runLater(() -> { netWorthLabel.setText(formatUsd(netWorth)); @@ -148,20 +137,12 @@ public void updateStatus(double netWorth, double cash, double invested, double s }); } - /** - * Returns the portfolio list view. - * - * @return the portfolio list - */ + /** @return the portfolio list view. */ public ListView getPortfolioList() { return portfolioList; } - /** - * Sets the callback invoked when the user clicks a share row. - * - * @param onShareSelected the callback to invoke with the selected share - */ + /** Sets the share selection callback. */ public void setOnShareSelected(Consumer onShareSelected) { this.onShareSelected = onShareSelected; } @@ -180,9 +161,7 @@ private static String formatUsd(double amount) { return "$" + String.format("%,.2f", amount); } - /** - * List cell that renders a single share holding as a four-column grid row. - */ + /** Renders a single share holding row. */ private class ShareCell extends ListCell { private static final double COL_SYMBOL_MIN = 120; diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/FilePickerApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/FilePickerApp.java index bf6f117..b165959 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/FilePickerApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/FilePickerApp.java @@ -18,9 +18,7 @@ import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -/** - * Represents a FilePickerApp class. - */ +/** File picker app. */ public class FilePickerApp extends Popup { private static final String FILTER = ".csv"; @@ -277,18 +275,12 @@ private static String formatSize(final long bytes) { } - /** - * Sets the onfileconfirmed. - * - * @param callback the new callback - */ + /** Sets onFileConfirmed callback. */ public void setOnFileConfirmed(final Consumer callback) { this.onFileConfirmed = callback; } - /** - * Show method. - */ + /** Shows the picker. */ @Override public void show() { selectedFile = null; @@ -298,9 +290,7 @@ public void show() { super.show(); } - /** - * Hide method. - */ + /** Hides the picker. */ @Override public void hide() { super.hide(); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/GameOverApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/GameOverApp.java index 64c5e2a..c0cb8f8 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/GameOverApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/GameOverApp.java @@ -8,9 +8,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.VBox; -/** - * Full-screen modal shown when the player runs out of lives. - */ +/** Modal shown on game over. */ public class GameOverApp extends Popup { private final Button startOverButton = new Button("Start Over"); @@ -47,14 +45,12 @@ private void buildLayout() { content.getChildren().setAll(inner); } - /** Wired by the controller to return to the start screen. */ + /** @return start over button. */ public Button getStartOverButton() { return startOverButton; } - /** - * Show method. - */ + /** Shows the app. */ @Override public void show(){ super.show(); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/HustlersApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/HustlersApp.java index 935f906..10c61fc 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/HustlersApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/HustlersApp.java @@ -16,11 +16,7 @@ import java.util.LinkedHashMap; import java.util.Map; -/** - * A popup for the Hustler's University tutorial app. - * Provides a wiki-style interface with a sidebar and scrollable content area - * covering all core game mechanics. - */ +/** Tutorial app popup. */ public class HustlersApp extends Popup { private static final String BG_ROOT = "#ffffff"; @@ -39,9 +35,7 @@ public class HustlersApp extends Popup { private Label chapterTitleLabel; private final Map chapters = new LinkedHashMap<>(); - /** - * Constructs the Hustler's University popup. - */ + /** Constructs the Hustlers app. */ public HustlersApp() { super(720, 480, 80, 60, App.HUSTLERS); buildChapters(); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java index 74c44bc..b1a2609 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java @@ -3,15 +3,10 @@ import edu.ntnu.idi.idatt2003.gruppe42.Model.App; import edu.ntnu.idi.idatt2003.gruppe42.View.Popup; -/** - * A popup for the Mail app. - */ +/** Mail app popup. */ public class MailApp extends Popup { - /** - * Constructs a new Mail popup. - * - */ + /** Constructs the Mail app. */ public MailApp() { super(400, 300, 140, 140, App.MAIL); // Add Mail specific content here diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/NewsApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/NewsApp.java index e8235d3..170b043 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/NewsApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/NewsApp.java @@ -3,14 +3,10 @@ import edu.ntnu.idi.idatt2003.gruppe42.Model.App; import edu.ntnu.idi.idatt2003.gruppe42.View.Popup; -/** - * A popup for the News app. - */ +/** News app popup. */ public class NewsApp extends Popup { - /** - * Constructs a new News popup. - */ + /** Constructs the News app. */ public NewsApp() { super(400, 300, 180, 180, App.NEWS); // Add news-specific content here diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/StockApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/StockApp.java index ac89570..f66ad9f 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/StockApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/StockApp.java @@ -20,9 +20,7 @@ import javafx.scene.layout.VBox; import javafx.scene.control.Label; -/** - * A popup for the Stock app. - */ +/** Popup for the Stock app. */ public class StockApp extends Popup { private final ListView stockList; @@ -33,11 +31,7 @@ public class StockApp extends Popup { private final Button backButton; private final Receipt receipt; - /** - * Constructs a new Stock popup. - * - * @param player the player performing transactions - */ + /** Constructs the Stock app. */ public StockApp(final Player player) { super(500, 450, 140, 140, App.STOCK); @@ -72,20 +66,14 @@ public StockApp(final Player player) { showSearchPage(); } - /** - * Displays the stock search page. - */ + /** Shows stock search page. */ public void showSearchPage() { content.setPadding(new Insets(20)); content.setSpacing(20); content.getChildren().setAll(searchField, stockList); } - /** - * Displays the detail page for a specific stock. - * - * @param stock the stock to display - */ + /** Shows stock detail page. */ public void showStockPage(final Stock stock) { content.getChildren().clear(); @@ -126,11 +114,7 @@ public void showStockPage(final Stock stock) { } - /** - * Updates the price label with the current sales price of the given stock. - * - * @param stock the stock whose price should be displayed - */ + /** Updates the price label. */ public void updatePriceLabel(final Stock stock) { if (priceLabel != null) { Platform.runLater(() -> @@ -139,56 +123,32 @@ public void updatePriceLabel(final Stock stock) { } } - /** - * Returns the search field. - * - * @return the search field - */ + /** @return the search field. */ public TextField getSearchField() { return searchField; } - /** - * Returns the stock list view. - * - * @return the stock list view - */ + /** @return the stock list view. */ public ListView getStockList() { return stockList; } - /** - * Returns the quantity spinner. - * - * @return the quantity spinner - */ + /** @return quantity spinner. */ public Spinner getQuantitySpinner() { return quantitySpinner; } - /** - * Returns the confirm/trade button. - * - * @return the confirm button - */ + /** @return confirm button. */ public Button getConfirmButton() { return confirmButton; } - /** - * Returns the receipt component. - * - * @return the receipt - */ + /** @return receipt component. */ public Receipt getReceipt() { return receipt; } - /** - * Returns the back button. - * - * @return the back button - */ + /** @return back button. */ public Button getBackButton() { return backButton; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java index 7195ad1..b2f39f6 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java @@ -10,12 +10,7 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; -/** - * Compact, reusable warning popup used across the entire game. - * - *

The close button is always re-wired by the configure methods so it - * mirrors the appropriate dismissal action.

- */ +/** Compact, reusable warning popup. */ public final class WarningApp extends Popup { private final Label iconLabel = new Label(); @@ -65,15 +60,7 @@ public WarningApp() { content.getChildren().setAll(inner); } - /** - * Configures for a single-button (dismiss-only) scenario. - * The secondary button is hidden. The close button mirrors the primary. - * - * @param icon emoji icon shown at the top - * @param title bold heading inside the card - * @param message body text below the heading - * @param primaryLabel label on the single action button - */ + /** Configures for single-button scenario. */ public void configure( final String icon, final String title, @@ -93,16 +80,7 @@ public void configure( getCloseButton().setOnAction(event -> primaryButton.fire()); } - /** - * Configures for a two-button (choice) scenario. - * The secondary button is the "safe" cancel option; the close button mirrors it. - * - * @param icon emoji icon shown at the top - * @param title bold heading inside the card - * @param message body text below the heading - * @param secondaryLabel label on the left / cancel button - * @param primaryLabel label on the right / action button - */ + /** Configures for two-button scenario. */ public void configure( final String icon, final String title, @@ -124,20 +102,18 @@ public void configure( getCloseButton().setOnAction(event -> secondaryButton.fire()); } - /** - * Show method. - */ + /** Shows the app. */ @Override public void show() { super.show(); } - /** The right-side action button (always visible). Wire with {@code setOnAction}. */ + /** @return primary button. */ public Button getPrimaryButton() { return primaryButton; } - /** The left-side cancel button (visible only in double mode). */ + /** @return secondary button. */ public Button getSecondaryButton() { return secondaryButton; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WeekendRapportApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WeekendRapportApp.java index 1485e07..a9cb75c 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WeekendRapportApp.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WeekendRapportApp.java @@ -16,20 +16,7 @@ import javafx.scene.layout.Region; import javafx.scene.layout.VBox; -/** - * End-of-week financial report shown every Saturday. - * - *

Designed to read like a real weekly statement:

- *
    - *
  1. Player summary: the week's net income, large and color-coded
  2. - *
  3. Verdict: a one-line mood label (e.g. "Strong week")
  4. - *
  5. Receipts: each transaction rendered with the shared {@link Receipt}
  6. - *
  7. Footer: cash, rent, and balance — with the final balance large and colored
  8. - *
- * - *

Dismissed only via the "Continue to Sunday" button or by clicking the - * dim overlay (wired by {@code DesktopViewController}).

- */ +/** End-of-week financial report. */ public class WeekendRapportApp extends Popup { private static final BigDecimal STRONG_WEEK_THRESHOLD = new BigDecimal("50.00"); @@ -250,9 +237,7 @@ static String formatBalance(BigDecimal amount) { return "$" + String.format("%,.2f", amount); } - /** - * Show method. - */ + /** Shows the rapport. */ @Override public void show(){ super.show(); diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java index 680339e..7946f71 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java @@ -21,10 +21,7 @@ import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; -/** - * Abstract base class for all draggable popup windows. - * Only responsible for building and exposing UI components. - */ +/** Base class for draggable popups. */ public abstract class Popup { private static final boolean DEV_CSS_RELOAD = true; @@ -187,10 +184,7 @@ private String resource(final String path) { return Objects.requireNonNull(getClass().getResource(path)).toExternalForm(); } - /** - * Binds this popup's layoutX/Y so it is always centered inside its parent. - * Safe to call before or after the wrapper is added to the scene graph. - */ + /** Centers the popup in its parent. */ public void centerInParent() { Runnable bind = () -> { if (wrapper.getParent() instanceof Pane pane) { @@ -204,53 +198,33 @@ public void centerInParent() { wrapper.parentProperty().addListener((obs, oldParent, newParent) -> bind.run()); } - /** - * Shows the popup by setting its visibility to true and bringing it to the front. - */ + /** Shows the popup. */ public void show() { wrapper.setVisible(true); wrapper.toFront(); } - /** - * Hides the popup by setting its visibility to false. - */ + /** Hides the popup. */ public void hide() { wrapper.setVisible(false); } - /** - * Returns the type. - * - * @return the value - */ + /** @return the type. */ public App getType() { return type; } - /** - * Returns the root. - * - * @return the value - */ + /** @return the root wrapper. */ public StackPane getRoot() { return wrapper; } - /** - * Returns the header. - * - * @return the value - */ + /** @return the header. */ public HBox getHeader() { return header; } - /** - * Returns the closebutton. - * - * @return the value - */ + /** @return the close button. */ public Button getCloseButton() { return closeButton; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java index 9d8cefc..bf93450 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java @@ -73,21 +73,13 @@ public enum ModalLayer { RAPPORT, WARNING, GAME_OVER } private Button nextWeekButton; private Button settingsButton; - /** - * Creates a new DesktopView with the given controller. - * - * @param controller the controller for this view - */ + /** Constructs the desktop view. */ public DesktopView(final DesktopViewController controller) { this.controller = controller; this.root = new BorderPane(); } - /** - * Returns the root node of this view. - * - * @return the root BorderPane - */ + /** @return the root node. */ public BorderPane getRoot() { if (root.getCenter() == null) { gridArea = createGrid(); @@ -159,21 +151,12 @@ private String devCopyToTemp(final String sourcePath) throws Exception { } - /** - * Registers a popup root to be managed by this view. - * - * @param popupRoot the root node of the popup - */ + /** Registers a popup root. */ public void registerPopup(final Node popupRoot) { popupRoots.add(popupRoot); } - /** - * Registers a modal root for a specific layer. - * - * @param layer the layer to register for - * @param modalRoot the root node of the modal - */ + /** Registers a modal root. */ public void registerModal(final ModalLayer layer, final Node modalRoot) { switch (layer) { case RAPPORT -> rapportRoot = modalRoot; @@ -182,12 +165,7 @@ public void registerModal(final ModalLayer layer, final Node modalRoot) { } } - /** - * Returns the overlay pane for a specific layer. - * - * @param layer the layer to get the overlay for - * @return the overlay Pane - */ + /** @return the overlay pane. */ public Pane getOverlay(final ModalLayer layer) { return switch (layer) { case RAPPORT -> rapportOverlay; @@ -196,21 +174,13 @@ public Pane getOverlay(final ModalLayer layer) { }; } - /** - * Activates a modal layer. - * - * @param layer the layer to activate - */ + /** Activates modal layer. */ public void enterLayer(final ModalLayer layer) { activeLayers.add(layer); recompute(); } - /** - * Deactivates a modal layer. - * - * @param layer the layer to deactivate - */ + /** Deactivates modal layer. */ public void exitLayer(final ModalLayer layer) { activeLayers.remove(layer); recompute(); @@ -407,30 +377,17 @@ private String resource(final String path) { return getClass().getResource(path).toExternalForm(); } - /** - * Updates the player name in the UI. - * - * @param name the new player name - */ + /** Updates player name. */ public void updatePlayerName(final String name) { Platform.runLater(() -> playerLabel.setText("User: " + name)); } - /** - * Updates the clock in the UI. - * - * @param time the new time string - */ + /** Updates clock. */ public void updateClock(final String time) { Platform.runLater(() -> clockLabel.setText(time)); } - /** - * Updates the day in the UI. - * - * @param day the new day string - * @param isSunday whether the new day is Sunday - */ + /** Updates day. */ public void updateDay(final String day, final boolean isSunday) { Platform.runLater(() -> { dayLabel.setText(day); @@ -438,47 +395,27 @@ public void updateDay(final String day, final boolean isSunday) { }); } - /** - * Updates the week in the UI. - * - * @param week the new week string - */ + /** Updates week. */ public void updateWeek(final String week) { Platform.runLater(() -> weekLabel.setText(week)); } - /** - * Updates the weather in the UI. - * - * @param weather the new weather description - */ + /** Updates weather. */ public void updateWeather(final String weather) { Platform.runLater(() -> weatherLabel.setText(weather)); } - /** - * Updates the temperature in the UI. - * - * @param temperature the new temperature - */ + /** Updates temperature. */ public void updateTemperature(final String temperature) { Platform.runLater(() -> tempLabel.setText(temperature + "°C")); } - /** - * Returns the nextweekbutton. - * - * @return the value - */ + /** @return the next week button. */ public Button getNextWeekButton() { return nextWeekButton; } - /** - * Returns the settingsbutton. - * - * @return the value - */ + /** @return the settings button. */ public Button getSettingsButton() { return settingsButton; } diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java index d5f6125..fb84c9e 100644 --- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java +++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java @@ -12,9 +12,7 @@ import java.util.Objects; -/** - * Represents a StartView class. - */ +/** Start screen view. */ public class StartView { // Set to false (or delete this + all DEV_CSS_RELOAD blocks) before release. @@ -28,11 +26,7 @@ public class StartView { private final BorderPane root = new BorderPane(); - /** - * Returns the root. - * - * @return the value - */ + /** @return the root node. */ public BorderPane getRoot() { if (!root.getChildren().isEmpty()) { return root; // already built @@ -149,19 +143,12 @@ private String copyToTemp(String sourcePath) throws Exception { return tmp.toUri().toString(); } - /** - * Returns the usernamefield. - * - * @return the value - */ + /** @return the username field. */ public TextField getUsernameField() { return usernameField; } - /** - * Getter for the difficulty mode the user has selected. - * @return Difficulty - */ + /** @return selected difficulty mode. */ public String getSelectedMode() { RadioButton selectedMode = (RadioButton) startingMoneyGroup.getSelectedToggle(); if (selectedMode == null) { @@ -170,20 +157,12 @@ public String getSelectedMode() { return selectedMode.getText(); } - /** - * Returns the loginbutton. - * - * @return the value - */ + /** @return login button. */ public Button getLoginButton() { return loginButton; } - /** - * Returns the settingsbutton. - * - * @return the value - */ + /** @return settings button. */ public Button getSettingsButton() { return settingsButton; }