From 7c1fce35bb3987e1311511194fd4c3f3e67679a5 Mon Sep 17 00:00:00 2001 From: Keerthana Srinivasan Date: Fri, 29 Oct 2021 01:17:50 -0400 Subject: [PATCH] Completed Lab --- AliceAndBobEngine.java | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/AliceAndBobEngine.java b/AliceAndBobEngine.java index 28b5e05..af3430a 100644 --- a/AliceAndBobEngine.java +++ b/AliceAndBobEngine.java @@ -4,13 +4,19 @@ * @date 5/19/21 5:05 PM */ public class AliceAndBobEngine { + private String name1 = "Alice"; + private String name2 = "Bob"; /** * return `true` if the input value is "Alice" * @param input - this value is variable: it has the potential to be many things * @return `true` if `input` is "Alice" */ public Boolean isAlice(String input) { - return null; + if(input.equals(name1)) + return true; + else + return false; + } /** @@ -19,7 +25,11 @@ public Boolean isAlice(String input) { * @return `true` if `input` is "Bob" */ public Boolean isBob(String input) { - return null; + if(input.equals(name2)) + return true; + else + return false; + } /** @@ -28,7 +38,11 @@ public Boolean isBob(String input) { * @return `true` if `input` is "Alice" or "Bob" */ public Boolean isAliceOrBob(String input) { - return null; + if(input.equals(name1) || input.equals(name2)) + return true; + else + return false; + } /** @@ -42,6 +56,12 @@ public Boolean isAliceOrBob(String input) { * @return respective String value */ public String getGreeting(String input) { - return null; + if(input.equals(name1)) + return "Hello, Alice!"; + else if(input.equals(name2)) + return "Hello, Bob!"; + else + return "Begone, " + input + "! You're a stranger!"; + } }