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
34 lines (29 loc) · 769 Bytes
/
TooLargeTooSmall.java
File metadata and controls
34 lines (29 loc) · 769 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
/**
* 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) {
//if guess is greater than chosenNum, then chosenNum = 1
//if less than, then -1
//if equal then 0
int output;
if (g > chosenNum){
output = 1;
} else if (g < chosenNum) {
output = -1;
} else {
output = 0; }
return output;
}
}