-
Notifications
You must be signed in to change notification settings - Fork 0
/
Computer_Choices.java
32 lines (28 loc) · 1.14 KB
/
Computer_Choices.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
/* Inorder to successfully execute this file you need to download the TicTacToeGame.java as well else it will not work*/
// develped by sachin sharma
// github --> Sachinsharma01
package Personal_Projects;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Computer_Choices {
int System_choice() {
int system_choice = (int) (10 * Math.random());
if (system_choice == 0)
system_choice = (int) (10 * Math.random());
return system_choice;
}
int user_choice(){
Scanner sc = new Scanner(System.in);
System.out.print("Enter the place you want to insert your character : ");
int user;
// handling Exception if user enter other than integer
try {
user = sc.nextInt();
// return user;
} catch (InputMismatchException e) {
System.out.print("Please Enter the valid Choice : ");
user = sc.nextInt();
}
return user;
}
}