Skip to content
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
38 changes: 30 additions & 8 deletions AliceAndBobEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions GetGreetingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions IsAliceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);}
}

}