Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

never gonna give you up #106

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/main/java/com/mg105/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/////////////////
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/mg105/interface_adapters/Web.java
Original file line number Diff line number Diff line change
@@ -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;
}
13 changes: 12 additions & 1 deletion src/main/java/com/mg105/interface_adapters/WinDisplay.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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
Expand All @@ -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;
}

/**
Expand All @@ -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);
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/mg105/user_interface/NeverGonnaGiveYouUp.java
Original file line number Diff line number Diff line change
@@ -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"));
}


}