Skip to content

Commit

Permalink
Add checks for greetings and modified GUI of dialog box
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEnHao committed Sep 13, 2020
1 parent c938ce0 commit 5b019f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/main/java/duke/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class Ui {
private static final String CIAO ="Spero di rivederti presto\n";
private static final String CONVO_START = GREETING;
private static final String END = "|end|ciao|bye|close|exit|nights|shutdown|";
private static final String USER_GREETINGS = "|hi|hey|wassup|";

private static final Controller CONTROLLER = Controller.init();

private boolean enterPasswordMode = false;
private boolean confirmPasswordMode = false;
private boolean hasBeenGreeted = false;
private String password;


Expand Down Expand Up @@ -62,10 +64,15 @@ public String takeInputAndReturn(String s) {
return "You are somebody new! Please state your user password.";
}
// Initiating a conversation with duke with 'hi'
if (s.length() == 3 && s.contains("hey")) {
if (!hasBeenGreeted && USER_GREETINGS.contains("|" + s + "|")) {
hasBeenGreeted = true;
return CONVO_START;
}

if (hasBeenGreeted && USER_GREETINGS.contains("|" + s + "|")) {
return "Why are you greeting me again?";
}

String reply = CONTROLLER.parseAndExec(s);

return reply;
Expand Down
20 changes: 12 additions & 8 deletions src/main/resources/view/DialogBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.effect.Reflection?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>

<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
style="-fx-border-color: lightgrey; -fx-border-radius: 15px;
-fx-border-width: 2px;" >
<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" style="-fx-border-color: silver; -fx-border-radius: 5px; -fx-border-width: 5px;" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="dialog" text="Label" wrapText="true" style="-fx-font-size: 13; -fx-padding: 0 20 0 20;" minHeight="-Infinity"/>
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true"
/>
<Label fx:id="dialog" minHeight="-Infinity" style="-fx-font-size: 13; -fx-padding: 0 20 0 20;" text="Label" wrapText="true" />
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true">
<effect>
<Reflection />
</effect></ImageView>
</children>
<padding>
<Insets bottom="15.0" left="5.0" right="5.0" top="15.0" />
</padding>
</fx:root>
<effect>
<DropShadow />
</effect>
</fx:root>

0 comments on commit 5b019f3

Please sign in to comment.