-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.java
153 lines (119 loc) · 3.92 KB
/
Game.java
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package Anteryami_GameZone;
import java.util.Scanner;
import Anteryami_GameZone.Sudoku_Game.Sudoku;
import Anteryami_GameZone.Tic_Tac_Toe.TicTacToe_Game;
public class Game {
// With the Help of TicTacToe_Game Class and Sudoku Class The Game Code Make In This Class.
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
System.out.println("--------Well-Come To World Anteryami_GameZone zone!--------");
while(true) {
System.out.println("\n1.Tik-Toc-Toe");
System.out.println("2.Sudoku Master");
System.out.println("3.Exit:");
int choice=sc.nextInt();
if(choice==1) {
System.out.println("Well-Come to Game....Tik-Toc-Toe");
System.out.println("Please Enter your Hero:");
String human=Character.toString(sc.next().charAt(0));
System.out.println("Please Enter your Enemy:");
String bot=Character.toString(sc.next().charAt(0));
while(true) {
TicTacToe_Game game=new TicTacToe_Game(human,bot);
System.out.println("Hero = "+game.GetHumanChoice()+" Enemy = "+game.GetBotChoice());
System.out.println("Let Started the Gme!!-->");
game.display();
System.out.println("Select the Mode Of Game");
System.out.println("1.Easy");
System.out.println("2.Medium");
System.out.println("3.Hard");
int level=sc.nextInt();
boolean f=false;
while(!game.isfull()) {
while(true) {
System.out.println("Your Tern Enter position 1 base indexing(Like (1,1)):");
int i=sc.nextInt();
int j=sc.nextInt();
if(game.HumanTern(i, j)) {
break;
}
System.out.println("Enter Right position:");
}
game.display();
if(game.isWinner()) {
f=true;
break;
}
if(game.isfull()) break;
System.out.println("UI Tern:.........:");
game.UITern(level);
game.display();
if(game.isWinner()) {
f=true;
break;
}
}
if(f) {
if(game.GetWinner()==human) {
System.out.println("You Win,the Game. YEH");
}
else {
System.out.println("Better Luck Next Time,You Loss the Game.");
}
}
else {
System.out.println("Math tie,OH You Play Well.");
}
System.out.println("Enter 2 for Play Again.(1 for break):");
if(sc.nextInt()==1) break;
}
}
else if(choice==2){
while(true) {
System.out.println("Well-Come to the Sudoku Game---->");
System.out.println("Select the Mode Of Game");
System.out.println("1.Easy");
System.out.println("2.Medium");
System.out.println("3.Hard");
int level=sc.nextInt();
Sudoku game=new Sudoku(level);
game.Sudoku_Borad_Creater();
boolean f=true;
while(!game.isfull()) {
if(f==true) game.show_Board(1);
System.out.println("Your Tern Enter position 1 base indexing(Like (1,1)):");
int i=sc.nextInt();
int j=sc.nextInt();
System.out.println("Enter the Number for position "+i+" and "+j);
int v=sc.nextInt();
if(!game.humanTern(i, j, v)) {
System.out.println("Enter valid position(at the number 0 present) or number(must be 1 to 9):");
f=false;
}
else{
f=true;
}
}
if(game.isWinner()) {
game.show_Board(1);
System.out.println("You Win,the Game. YEH");
}
else {
System.out.println("Better Luck Next Time,You Loss the Game.");
System.out.println("Enter yes if you Want to see ans or No for next game:");
if(sc.next().equals("yes")) {
System.out.println("Ans. of Sudoku is:");
game.show_Board(2);
}
}
System.out.println("Enter 2 for Play Again.(1 for break):");
if(sc.nextInt()==1) break;
}
}
else {
break;
}
}
System.out.println("Thank You");
}
}