Skip to content

Commit

Permalink
cleaned up the javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
peretr committed May 15, 2026
1 parent 31eb876 commit f3f9520
Show file tree
Hide file tree
Showing 34 changed files with 244 additions and 1,108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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<String> callback) {
onPlayerNameChanged = callback;
}

/**
* Sets the ongradientchanged.
*
* @param callback the new callback
*/
/** Sets onGradientChanged callback. */
public void setOnGradientChanged(final Consumer<GradientConfig> 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() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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<Stock> createStockCell() {
return new ListCell<>() {
private final HBox row = new HBox(15);
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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()))
Expand All @@ -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(() ->
Expand All @@ -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());
Expand Down
Loading

0 comments on commit f3f9520

Please sign in to comment.