diff --git a/AliceAndBobEngine.java b/AliceAndBobEngine.java index 28b5e05..65bcfb2 100644 --- a/AliceAndBobEngine.java +++ b/AliceAndBobEngine.java @@ -6,42 +6,64 @@ public class AliceAndBobEngine { /** * 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" + * @return */ public Boolean isAlice(String input) { - return null; + if (input == "Alice") { + return true; + } + return false; } /** * return `true` if the input value is "Bob" + * * @param input - this value is variable: it has the potential to be many things * @return `true` if `input` is "Bob" */ public Boolean isBob(String input) { - return null; + if (input == "Bob") { + return true; + } + return false; } /** * return `true` if the input value is "Alice" or "Bob" + * * @param input - this value is variable: it has the potential to be many things * @return `true` if `input` is "Alice" or "Bob" */ public Boolean isAliceOrBob(String input) { - return null; + if (input == "Alice") { + return true; + } + if (input == "Bob") { + return true; + } + return false; } /** * if the input value is "Alice" or "Bob", then - * return "Hello PERSONSNAME!", + * return "Hello PERSONSNAME!", * otherwise - * return "Begone, PERSONNAME! You're a stranger!", + * return "Begone, PERSONNAME! You're a stranger!", * where `PERSONNAME` is replaced with the person's name respectively. * * @param input - this value is variable: it has the potential to be many things * @return respective String value */ public String getGreeting(String input) { - return null; + if (input == "Alice" || input == "Bob") { + return "Hello, " + input + "!"; + } + else { return "Begone, " + input + "! You're a stranger!"; + + } + + } -} +} // last one diff --git a/GetGreetingTest.java b/GetGreetingTest.java index 4ac8e8d..c62326e 100644 --- a/GetGreetingTest.java +++ b/GetGreetingTest.java @@ -16,7 +16,7 @@ private void testGetGreeting(String input, String expected) { String actual = evaluator.getGreeting(input); // then - Assert.assertEquals(expected, actual); + Assert.assertEquals(actual, expected); } @Test @@ -36,7 +36,7 @@ public void testGetGreetingBob() { @Test public void testGetGreetingStranger() { String[] strangerNames = "Leon Dolio Kris Nobles Desa Lossie Nancy".split(" "); - for(String strangerName : strangerNames) { + for (String strangerName : strangerNames) { String expected = "Begone, " + strangerName + "! You're a stranger!"; testGetGreeting(strangerName, expected); } diff --git a/IsAliceTest.java b/IsAliceTest.java index 7b26328..dc3ff48 100644 --- a/IsAliceTest.java +++ b/IsAliceTest.java @@ -27,9 +27,8 @@ public void testIsAliceTrue() { @Test public void testIsAliceFalse() { - for(String word : "The Quick Brown Fox Jumps Over The Lazy Dog".split(" ")) { - testIsAlice(word, false); - } + for(String word : "The Quick Brown Fox Jumps Over The Lazy Dog".split(" ")) + { testIsAlice(word, false);} } }