-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPartita.java
70 lines (61 loc) · 1.94 KB
/
Partita.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
package prg.esamiPassati.es4;
import java.util.Scanner;
public class Partita{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String choice;
do{
System.out.println("MENU'");
System.out.println("1. Gioca contro un altro giocatore");
System.out.println("2. Gioca contro il computer");
System.out.println("3. Esci dal gioco");
System.out.println();
System.out.print("Scelta: ");
choice = input.nextLine();
switch(choice){
case "1":
Giocatore first = new GiocatoreUmano();
Giocatore second = new GiocatoreUmano();
Scacchiera scacchiera = new Scacchiera(first, second);
scacchiera.printScacchiera();
do{
//Mossa primo giocatore
scacchiera.inputMossa(first, first.gioca());
scacchiera.printScacchiera();
if(scacchiera.win() || scacchiera.end()){
break;
}
//Mossa secondo giocatore
scacchiera.inputMossa(second, second.gioca());
scacchiera.printScacchiera();
}while(!scacchiera.win() && !scacchiera.end());
scacchiera.printScacchiera();
break;
case "2":
first = new GiocatoreUmano();
second = new GiocatoreComputer();
scacchiera = new Scacchiera(first, second);
scacchiera.printScacchiera();
do{
//Mossa primo giocatore
scacchiera.inputMossa(first, first.gioca());
scacchiera.printScacchiera();
if(scacchiera.win() || scacchiera.end()){
break;
}
//Mossa secondo giocatore
scacchiera.inputMossa(second, second.gioca());
scacchiera.printScacchiera();
}while(!scacchiera.win() && !scacchiera.end());
break;
case "3":
//termina programma
break;
default:
System.out.println("Scelta non valida. Riprova.");
break;
}
}while(!choice.equals("3"));
System.out.println("PROGRAMMA TERMINATO");
}
}