diff --git a/src/main/java/com/mg105/Application.java b/src/main/java/com/mg105/Application.java index 782a12f..137f611 100644 --- a/src/main/java/com/mg105/Application.java +++ b/src/main/java/com/mg105/Application.java @@ -145,7 +145,8 @@ public void start(Stage primaryStage) { /////WinGame Scene///// ReplayGeneratorButton winButton = new ReplayGeneratorButton(replayGeneratorInterpreter, sceneController, Toggler.ToggleableComponent.WIN_MENU); WinMenu winMenu = new WinMenu(winButton); - WinDisplay winDisplay = new WinDisplay(sceneController, roomGetter, replayGenerator); + NeverGonnaGiveYouUp funny = new NeverGonnaGiveYouUp(); + WinDisplay winDisplay = new WinDisplay(sceneController, roomGetter, replayGenerator, funny); roomUpdater.addObserver(winDisplay); drawableComponents.put(Toggler.ToggleableComponent.WIN_MENU, winMenu); ///////////////// diff --git a/src/main/java/com/mg105/interface_adapters/Web.java b/src/main/java/com/mg105/interface_adapters/Web.java new file mode 100644 index 0000000..7e692f9 --- /dev/null +++ b/src/main/java/com/mg105/interface_adapters/Web.java @@ -0,0 +1,13 @@ +package com.mg105.interface_adapters; + +/** + * An interface that make NeverGonnaGiveYouUP java class follow the clean architecture. + */ +public interface Web { + + /** + * pop up a browser and going to the YouTube URL that play Never Gonna Give You Up song by Rick Astley. + * @throws Exception Exception + */ + void neverGonnaGiveYouUp() throws Exception; +} diff --git a/src/main/java/com/mg105/interface_adapters/WinDisplay.java b/src/main/java/com/mg105/interface_adapters/WinDisplay.java index 267ba56..1049b2f 100644 --- a/src/main/java/com/mg105/interface_adapters/WinDisplay.java +++ b/src/main/java/com/mg105/interface_adapters/WinDisplay.java @@ -1,8 +1,10 @@ package com.mg105.interface_adapters; import com.mg105.use_cases.ReplayGenerator; + import com.mg105.use_cases.map.RoomGetterInterface; + import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -13,6 +15,7 @@ public class WinDisplay implements PropertyChangeListener { private final Toggler toggler; private final RoomGetterInterface roomGetter; private final ReplayGenerator replayGenerator; + private final Web rickAstley; /** * Construction for the WinDisplay interface adapter @@ -21,10 +24,11 @@ public class WinDisplay implements PropertyChangeListener { * @param roomGetter gets the current room of the player * @param replayGenerator generates a replay */ - public WinDisplay(Toggler toggler, RoomGetterInterface roomGetter, ReplayGenerator replayGenerator) { + public WinDisplay(Toggler toggler, RoomGetterInterface roomGetter, ReplayGenerator replayGenerator, Web neverGonnaGiveYouUp) { this.toggler = toggler; this.roomGetter = roomGetter; this.replayGenerator = replayGenerator; + this.rickAstley = neverGonnaGiveYouUp; } /** @@ -37,6 +41,13 @@ public WinDisplay(Toggler toggler, RoomGetterInterface roomGetter, ReplayGenerat public void propertyChange(PropertyChangeEvent evt) { if (roomGetter.isFinalRoom()) { replayGenerator.reviveCharacters(); + + try { + this.rickAstley.neverGonnaGiveYouUp(); + } catch (Exception e) { + throw new RuntimeException(e); + } + toggler.toggle(Toggler.ToggleableComponent.WIN_MENU); } } diff --git a/src/main/java/com/mg105/user_interface/NeverGonnaGiveYouUp.java b/src/main/java/com/mg105/user_interface/NeverGonnaGiveYouUp.java new file mode 100644 index 0000000..9ff0ec1 --- /dev/null +++ b/src/main/java/com/mg105/user_interface/NeverGonnaGiveYouUp.java @@ -0,0 +1,25 @@ +package com.mg105.user_interface; + +import com.mg105.interface_adapters.Web; + +import java.awt.*; +import java.net.URI; + +/** + * This Java class have the method that pop up a browser and going to the YouTube URL that play Never Gonna Give You Up song by Rick Astley. + */ +public class NeverGonnaGiveYouUp implements Web { + + + /** + * method for pop up a browser and going to the YouTube URL that play Never Gonna Give You Up song by Rick Astley. + * @throws Exception Exception + */ + @Override + public void neverGonnaGiveYouUp() throws Exception { + Desktop d = Desktop.getDesktop(); + d.browse(new URI("https://www.youtube.com/watch?v=dQw4w9WgXcQ")); + } + + +}