forked from Zipcoder/BlueJ.TooLargeTooSmall
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTooLargeTooSmall.java
More file actions
36 lines (31 loc) · 835 Bytes
/
TooLargeTooSmall.java
File metadata and controls
36 lines (31 loc) · 835 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
/**
* 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) {
int result = 0;
if (g < chosenNum) {
result = -1;
return result;
} else if (g == chosenNum) {
result = 0;
return result;
} else if (g > chosenNum) {
result = 1;
return result;
}
System.out.println(result + ", " + chosenNum + ", " + g);
return chosenNum;
}
}