forked from fenniless/BlueJ.TooLargeTooSmall
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTooLargeTooSmall.java
More file actions
37 lines (32 loc) · 850 Bytes
/
TooLargeTooSmall.java
File metadata and controls
37 lines (32 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Write a description of class TooLargeTooSmall here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TooLargeTooSmall {
private Integer chosenNum;
/**
* Constructor for objects of class TooLargeTooSmall
*/
public TooLargeTooSmall(Integer seed) {
// initialise instance variables
chosenNum = seed;
}
public Integer guess(Integer g) {
Integer result = 0;
if (chosenNum < g){
//This is when the guessed number is bigger than the chosen number
result = 1;
}
else if (chosenNum > g){
//This is when the guessed number is smaller than the chosen number
result = -1;
}
else {
//If other two fail, then chosent number should be equal to guessed number
result = 0;
}
return result;
}
}