From 9306d7587ade9b6e51d13f711784be0da02ae089 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 24 Jun 2021 17:57:57 -0400 Subject: [PATCH] Ran through the labs focusing on the use of conditional statements --- AliceAndBobEngine.java | 34 +++++++++++++--- package.bluej | 90 +++++++++++++++++++++++++++++++----------- 2 files changed, 96 insertions(+), 28 deletions(-) diff --git a/AliceAndBobEngine.java b/AliceAndBobEngine.java index 28b5e05..e9a7a45 100644 --- a/AliceAndBobEngine.java +++ b/AliceAndBobEngine.java @@ -10,16 +10,26 @@ public class AliceAndBobEngine { * @return `true` if `input` is "Alice" */ public Boolean isAlice(String input) { - return null; - } - + if ("Alice".equals(input)) { + 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 ("Bob".equals(input)) { + + return true; + + }; + return false; } /** @@ -28,7 +38,12 @@ public Boolean isBob(String input) { * @return `true` if `input` is "Alice" or "Bob" */ public Boolean isAliceOrBob(String input) { - return null; + if ("Alice".equals(input)) { + return true; + } else if ("Bob".equals(input)) { + return true; + }; + return false; } /** @@ -42,6 +57,13 @@ public Boolean isAliceOrBob(String input) { * @return respective String value */ public String getGreeting(String input) { - return null; + if ("Alice".equals(input)) { + return "Hello, Alice!"; + } else if ("Bob".equals(input)) { + return "Hello, Bob!"; + } else { + return "Begone, " + input + "! " + "You're a stranger!"; + } + } } diff --git a/package.bluej b/package.bluej index 143e572..a222de9 100644 --- a/package.bluej +++ b/package.bluej @@ -1,32 +1,78 @@ #BlueJ package file -editor.fx.0.height=0 -editor.fx.0.width=0 -editor.fx.0.x=0 -editor.fx.0.y=0 +dependency1.from=IsAliceTest +dependency1.to=AliceAndBobEngine +dependency1.type=UsesDependency +dependency2.from=IsBobTest +dependency2.to=AliceAndBobEngine +dependency2.type=UsesDependency +dependency3.from=IsAliceOrBobTest +dependency3.to=AliceAndBobEngine +dependency3.type=UsesDependency +dependency4.from=GetGreetingTest +dependency4.to=AliceAndBobEngine +dependency4.type=UsesDependency +editor.fx.0.height=736 +editor.fx.0.width=872 +editor.fx.0.x=408 +editor.fx.0.y=23 objectbench.height=101 -objectbench.width=776 +objectbench.width=383 package.divider.horizontal=0.6 -package.divider.vertical=0.8007380073800738 -package.editor.height=427 -package.editor.width=674 -package.editor.x=181 -package.editor.y=109 -package.frame.height=600 -package.frame.width=800 -package.numDependencies=0 -package.numTargets=1 +package.divider.vertical=0.7397590361445783 +package.editor.height=284 +package.editor.width=273 +package.editor.x=0 +package.editor.y=23 +package.frame.height=473 +package.frame.width=407 +package.numDependencies=4 +package.numTargets=6 package.showExtends=true package.showUses=true project.charset=UTF-8 -readme.height=58 +readme.height=60 readme.name=@README -readme.width=47 +readme.width=48 readme.x=10 readme.y=10 -target1.height=50 -target1.name=Main +target1.height=70 +target1.name=IsAliceTest target1.showInterface=false -target1.type=ClassTarget -target1.width=80 -target1.x=70 -target1.y=10 +target1.type=UnitTestTargetJunit4 +target1.width=120 +target1.x=0 +target1.y=60 +target2.height=70 +target2.name=IsBobTest +target2.showInterface=false +target2.type=UnitTestTargetJunit4 +target2.width=120 +target2.x=140 +target2.y=90 +target3.height=70 +target3.name=IsAliceOrBobTest +target3.showInterface=false +target3.type=UnitTestTargetJunit4 +target3.width=120 +target3.x=0 +target3.y=220 +target4.height=70 +target4.name=AliceAndBobEngine +target4.showInterface=false +target4.type=ClassTarget +target4.width=130 +target4.x=140 +target4.y=170 +target5.height=70 +target5.name=README.md +target5.type=TextTarget +target5.width=120 +target5.x=140 +target5.y=10 +target6.height=70 +target6.name=GetGreetingTest +target6.showInterface=false +target6.type=UnitTestTargetJunit4 +target6.width=120 +target6.x=0 +target6.y=310