From 6ae8392db7d42e0ec17fafb2884e7d9b0527bb0f Mon Sep 17 00:00:00 2001 From: Manny Date: Fri, 25 Jun 2021 00:02:12 -0400 Subject: [PATCH] Number guessing game --- TooLargeTooSmall.java | 18 +++++++++++++++--- package.bluej | 44 ++++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/TooLargeTooSmall.java b/TooLargeTooSmall.java index 4d45abf..10753d6 100644 --- a/TooLargeTooSmall.java +++ b/TooLargeTooSmall.java @@ -2,8 +2,8 @@ /** * Write a description of class TooLargeTooSmall here. * - * @author (your name) - * @version (a version number or a date) + * @author (Manny) + * @version (06-24-2021) */ public class TooLargeTooSmall { private Integer chosenNum; @@ -17,8 +17,20 @@ public TooLargeTooSmall(Integer seed) { } public Integer guess(Integer g) { + // compare g to chosen number + // if g > chosen number return 1 + // if g < chosen number return -1 + // else return 0 + if (g > chosenNum) { + int greaterNum = 1; + return greaterNum; + } else if (g < chosenNum) { + int lessNum = -1; + return lessNum; + } else { + return 0; + } - return chosenNum; } } \ No newline at end of file diff --git a/package.bluej b/package.bluej index abc5ce7..f79d076 100644 --- a/package.bluej +++ b/package.bluej @@ -3,27 +3,27 @@ dependency1.from=TooLargeTooSmallTest dependency1.to=TooLargeTooSmall dependency1.type=UsesDependency editor.fx.0.height=767 -editor.fx.0.width=1150 -editor.fx.0.x=448 -editor.fx.0.y=120 +editor.fx.0.width=808 +editor.fx.0.x=540 +editor.fx.0.y=101 objectbench.height=101 -objectbench.width=461 -package.divider.horizontal=0.6 -package.divider.vertical=0.8007380073800738 -package.editor.height=427 -package.editor.width=674 -package.editor.x=220 -package.editor.y=143 -package.frame.height=600 -package.frame.width=800 +objectbench.width=412 +package.divider.horizontal=0.6125730994152047 +package.divider.vertical=0.8025594149908593 +package.editor.height=432 +package.editor.width=586 +package.editor.x=1214 +package.editor.y=249 +package.frame.height=605 +package.frame.width=704 package.numDependencies=1 -package.numTargets=2 +package.numTargets=3 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.association=TooLargeTooSmallTest @@ -32,12 +32,18 @@ target1.name=TooLargeTooSmall target1.showInterface=false target1.type=ClassTarget target1.width=140 -target1.x=130 -target1.y=150 +target1.x=140 +target1.y=170 target2.height=50 target2.name=TooLargeTooSmallTest target2.showInterface=false target2.type=UnitTestTargetJunit4 target2.width=140 -target2.x=160 -target2.y=120 +target2.x=170 +target2.y=140 +target3.height=70 +target3.name=README.md +target3.type=TextTarget +target3.width=120 +target3.x=70 +target3.y=10