-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from einaskoi/bankApp
refactor the view to controller relationships to allow player to be d…
- Loading branch information
Showing
21 changed files
with
234 additions
and
71 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers; | ||
|
|
||
| public interface AppController { | ||
| void nextTick(); | ||
| } |
12 changes: 12 additions & 0 deletions
12
...in/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.AppStoreApp; | ||
|
|
||
| public class AppStoreController implements AppController { | ||
| public AppStoreController(AppStoreApp appStoreApp) { | ||
| } | ||
|
|
||
| @Override | ||
| public void nextTick() { | ||
| } | ||
| } |
22 changes: 21 additions & 1 deletion
22
...ain/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,24 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers; | ||
|
|
||
| public class BankAppController { | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.BankApp; | ||
|
|
||
| public class BankAppController implements AppController{ | ||
| private Player player; | ||
| private BankApp bankApp; | ||
|
|
||
| public BankAppController(BankApp bankApp, Player player) { | ||
| this.player = player; | ||
| this.bankApp = bankApp; | ||
| } | ||
| @Override | ||
| public void nextTick() { | ||
| System.out.println("[DEBUG] BankAppController.nextTick() - Updating Player Status"); | ||
| bankApp.updateStatus( | ||
| player.getNetWorth().doubleValue(), | ||
| player.getMoney().doubleValue(), | ||
| player.getPortfolio().getNetWorth().doubleValue(), | ||
| 0 // TODO: calculate growth | ||
| ); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package edu.ntnu.idi.idatt2003.gruppe42.Controller; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.AppController; | ||
| import edu.ntnu.idi.idatt2003.gruppe42.Model.Player; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Timer; | ||
| import java.util.TimerTask; | ||
|
|
||
| public class GameController { | ||
|
|
||
| private Player player; | ||
| private List<AppController> appControllers = new ArrayList<>(); | ||
| private Timer timer; | ||
|
|
||
| public GameController(Player player) { | ||
| this.player = player; | ||
| } | ||
|
|
||
| public void addAppController(AppController appController) { | ||
| appControllers.add(appController); | ||
| } | ||
|
|
||
| public void startGame() { | ||
| timer = new Timer(); | ||
|
|
||
| timer.scheduleAtFixedRate(new TimerTask() { | ||
| @Override | ||
| public void run() { | ||
| System.out.println("[DEBUG] Game Tick Started"); | ||
| for (AppController controller : appControllers) { | ||
| controller.nextTick(); | ||
| } | ||
| System.out.println("[DEBUG] Game Tick Finished"); | ||
| } | ||
| }, 0, 1000); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.