Skip to content

Commit

Permalink
Add name to greeting
Browse files Browse the repository at this point in the history
  • Loading branch information
astraindev committed Oct 15, 2020
1 parent d933d23 commit daaa487
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/java/com/isageek/blaztek/bot/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,20 @@ public void chat(String message) throws MessageNotParsedException {
log.println("My name is Bot. Who are you?");
} else if (message.equals("what is your name")) {
log.println("My name is Bot. What is your name?");
} else if (message.startsWith("i am") || message.startsWith("my name is")) {
log.println("Nice ot meet you!");
} else if (message.startsWith("i am")) {
if (message.length() > 5) {
String name = message.substring(5, 6).toUpperCase() + message.substring(6);
log.println("Nice ot meet you " + name + "!");
} else {
recite();
}
} else if (message.startsWith("my name is")) {
if (message.length() > 11) {
String name = message.substring(11, 12).toUpperCase() + message.substring(12);
log.println("Nice ot meet you " + name + "!");
} else {
recite();
}
} else if (message.equals("sad")) {
log.println("Indeed");
} else if (message.equals("you can't") || message.equals("you can not")) {
Expand Down

0 comments on commit daaa487

Please sign in to comment.