Skip to content

Einar/clean code #122

Merged
merged 2 commits into from
May 18, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers;

import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
import edu.ntnu.idi.idatt2003.gruppe42.Audio.Audio;
import edu.ntnu.idi.idatt2003.gruppe42.Controller.MarketController;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
Expand All @@ -12,8 +10,8 @@
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ListCell;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
Expand Down Expand Up @@ -72,7 +70,7 @@ public StockAppController(
}

/** Navigates to stock detail page. */
private void navigateToStock(final Stock stock) {
public void navigateToStock(final Stock stock) {
currentStock = stock;
stock.getStockGraph().setVisibility(true);
Platform.runLater(stock::updateStockGraph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
import edu.ntnu.idi.idatt2003.gruppe42.Model.Exchange;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
import edu.ntnu.idi.idatt2003.gruppe42.Model.StockFileHandler;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.StockApp;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;

/** Controller for the stock market. */
public final class MarketController {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package edu.ntnu.idi.idatt2003.gruppe42.Controller;

import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
import edu.ntnu.idi.idatt2003.gruppe42.Audio.Audio;
import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package edu.ntnu.idi.idatt2003.gruppe42.Controller;

import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
import edu.ntnu.idi.idatt2003.gruppe42.Audio.Audio;
import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.AppController;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Day;
import edu.ntnu.idi.idatt2003.gruppe42.Model.GameState;
import java.util.Random;

import javafx.application.Platform;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Transaction;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.GameOverApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WarningApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WeekendRapportApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WeekendReportApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView.ModalLayer;
import java.math.BigDecimal;
Expand All @@ -18,7 +18,7 @@ public final class DesktopDialogController {

private final Player player;
private final TimeAndWeatherController timeAndWeatherController;
private final WeekendRapportApp weekendRapportApp;
private final WeekendReportApp weekendReportApp;
private final WarningApp warningApp;
private final GameOverApp gameOverApp;
private DesktopView desktopView;
Expand All @@ -30,19 +30,19 @@ public final class DesktopDialogController {
*
* @param player the player model
* @param timeAndWeatherController the time and weather controller
* @param weekendRapportApp the weekend rapport app
* @param weekendReportApp the weekend rapport app
* @param warningApp the warning app
* @param gameOverApp the game over app
*/
public DesktopDialogController(
Player player,
TimeAndWeatherController timeAndWeatherController,
WeekendRapportApp weekendRapportApp,
WeekendReportApp weekendReportApp,
WarningApp warningApp,
GameOverApp gameOverApp) {
this.player = player;
this.timeAndWeatherController = timeAndWeatherController;
this.weekendRapportApp = weekendRapportApp;
this.weekendReportApp = weekendReportApp;
this.warningApp = warningApp;
this.gameOverApp = gameOverApp;

Expand Down Expand Up @@ -72,14 +72,14 @@ public void showWeekendRapport() {
player.deductRent(WEEKLY_RENT);
BigDecimal cashAfter = player.getMoney();

weekendRapportApp.populate(transactions, netIncome, cashBefore, WEEKLY_RENT, cashAfter);
weekendRapportApp.show();
weekendReportApp.populate(transactions, netIncome, cashBefore, WEEKLY_RENT, cashAfter);
weekendReportApp.show();
desktopView.enterLayer(ModalLayer.RAPPORT);
}

private void wireWeekendRapport() {
weekendRapportApp.getContinueButton().setOnAction(event -> {
weekendRapportApp.getRoot().setVisible(false);
weekendReportApp.getContinueButton().setOnAction(event -> {
weekendReportApp.getRoot().setVisible(false);
desktopView.exitLayer(ModalLayer.RAPPORT);
timeAndWeatherController.setDay(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.SettingsApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.StockApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WarningApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WeekendRapportApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WeekendReportApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView.ModalLayer;
import java.math.BigDecimal;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -49,7 +48,7 @@ public final class DesktopViewController {
private final MailController mailController;
private final DesktopDialogController dialogController;
private final DesktopComponentFactory componentFactory;
private final WeekendRapportApp weekendRapportApp = new WeekendRapportApp();
private final WeekendReportApp weekendReportApp = new WeekendReportApp();
private final WarningApp warningApp = new WarningApp();
private final GameOverApp gameOverApp = new GameOverApp();

Expand All @@ -73,7 +72,7 @@ public DesktopViewController(
this.popupsController = popupsController;
this.componentFactory = new DesktopComponentFactory(popupsController, mailController);
this.dialogController = new DesktopDialogController(
player, timeAndWeatherController, weekendRapportApp, warningApp, gameOverApp);
player, timeAndWeatherController, weekendReportApp, warningApp, gameOverApp);

this.desktopView = new DesktopView(this);
this.dialogController.setDesktopView(desktopView);
Expand Down Expand Up @@ -122,7 +121,7 @@ private List<Popup> initializeApps(GameController gameController, Path userSelec

bankApp.setOnShareSelected(share -> {
popupsController.show(App.STOCK);
stockApp.showStockPage(share.getStock());
stockAppController.navigateToStock(share.getStock());
});

stockAppController.setOnMarketClosed(this::showMarketClosedWarning);
Expand All @@ -147,22 +146,22 @@ private void setupPopupOverlay(List<Popup> popups) {
overlay.getChildren().add(p.getRoot());
}

weekendRapportApp.centerInParent();
weekendReportApp.centerInParent();
warningApp.centerInParent();
gameOverApp.centerInParent();

desktopView.registerModal(ModalLayer.RAPPORT, weekendRapportApp.getRoot());
desktopView.registerModal(ModalLayer.RAPPORT, weekendReportApp.getRoot());
desktopView.registerModal(ModalLayer.WARNING, warningApp.getRoot());
desktopView.registerModal(ModalLayer.GAME_OVER, gameOverApp.getRoot());

overlay.getChildren().addAll(
desktopView.getOverlay(ModalLayer.RAPPORT), weekendRapportApp.getRoot(),
desktopView.getOverlay(ModalLayer.RAPPORT), weekendReportApp.getRoot(),
desktopView.getOverlay(ModalLayer.WARNING), warningApp.getRoot(),
desktopView.getOverlay(ModalLayer.GAME_OVER), gameOverApp.getRoot()
);

desktopView.getOverlay(ModalLayer.RAPPORT).setOnMouseClicked(
event -> weekendRapportApp.getContinueButton().fire());
event -> weekendReportApp.getContinueButton().fire());
}

private void setupDesktopUI() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WarningApp;
import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.StartView;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.StartView;
import java.nio.file.Path;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.nio.file.Path;

/** JavaFX application entry point. */
public class Millions extends Application {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package edu.ntnu.idi.idatt2003.gruppe42.Model;

import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.SaleCalculator;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction;

import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.PurchaseCalculator;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.TransactionCalculator;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;

import java.math.BigDecimal;

/** Represents a stock purchase. */
public final class Purchase extends Transaction {
/** Constructs a purchase. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@

import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.scene.control.Button;
import javafx.scene.layout.Priority;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.paint.Color;
import javafx.geometry.Pos;
import javafx.scene.shape.Rectangle;

/**
* A popup for the app store app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
import java.util.LinkedHashMap;
import java.util.Map;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
Expand All @@ -13,8 +15,6 @@
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import java.util.LinkedHashMap;
import java.util.Map;

/** Tutorial app popup. */
public class HustlersApp extends Popup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import javafx.scene.layout.VBox;

/** End-of-week financial report. */
public class WeekendRapportApp extends Popup {
public class WeekendReportApp extends Popup {

private static final BigDecimal STRONG_WEEK_THRESHOLD = new BigDecimal("50.00");

Expand All @@ -33,7 +33,7 @@ public class WeekendRapportApp extends Popup {

private final Button continueButton = new Button("Continue to Sunday →");

public WeekendRapportApp() {
public WeekendReportApp() {
super(740, 620, 0, 0, App.WEEKENDRAPPORT);

getCloseButton().setOnAction(event -> continueButton.fire());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers.DesktopViewController;
import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
import edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components.DesktopBottomBar;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -12,17 +11,14 @@
import java.util.EnumSet;
import java.util.List;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.ntnu.idi.idatt2003.gruppe42.View.Views;

import java.util.Objects;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
Expand All @@ -8,9 +9,11 @@
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;

import java.util.Objects;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;

/** Start screen view. */
public class StartView {
Expand Down