forked from Dmitriy-G/JavaPrograms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameProcess.java
More file actions
52 lines (50 loc) · 1.92 KB
/
Copy pathGameProcess.java
File metadata and controls
52 lines (50 loc) · 1.92 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by Dima on 23.09.2015.
*/
public class GameProcess {
//Action
public static void main(String[] args) throws IOException {
System.out.println("Start Game");
User player=new User();
GameSupport gameSupport =new GameSupport();
StatisticMonitor statisticMonitor=new StatisticMonitor(player);
statisticMonitor.setStartRange(0);
statisticMonitor.setEndRange(100);
int tempNumber;
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
while (true){
statisticMonitor.setCountAttempt(1);
player.setUserAction(reader.readLine());
tempNumber=player.getUserNumber();
//Generated new number
if (gameSupport.getRequiredNumber()<0){
gameSupport.generatedNewNumber();
}
//Game process
if (tempNumber!=-1) {
if (tempNumber <= statisticMonitor.getStartRange() || tempNumber >= statisticMonitor.getEndRange()) {
statisticMonitor.viewStatistics(0);
statisticMonitor.setOutOfRange(1);
continue;
}
if (tempNumber == gameSupport.getRequiredNumber()) {
statisticMonitor.viewAllStatistics();
break;
} else {
if (tempNumber < gameSupport.getRequiredNumber()) {
statisticMonitor.setStartRange(tempNumber);
} else {
statisticMonitor.setEndRange(tempNumber);
}
statisticMonitor.viewStatistics(2);
}
}else {
statisticMonitor.viewStatistics(1);
}
statisticMonitor.setArchiveAttempts(tempNumber);
}
}
}