-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.java
68 lines (67 loc) · 2.54 KB
/
main.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
package tombola;
import java.util.Scanner;
//@author leona
public class main{
public static void main(String[]args){
//DECLARATIONS
int randomNumber,cout=0,c=0;
int[]table;
//INPUT
Scanner keyb=new Scanner(System.in);
main callMethods=new main();
//OPERATIONS
//Console clearing (disabled due to a visual bug)
//callMethods.clearScreen();
table=new int[90];
while(c<90){
//Randomize a number between 1 and 90
randomNumber=(int)(Math.random()*90)+1;
//randomVerifier method verifies if the random number has already been randomized before
if(callMethods.randomVerifier(table,randomNumber)){
table[randomNumber-1]=randomNumber;
//Console clearing (disabled due to a visual bug)
//callMethods.clearScreen();
System.out.println("========================================================================================================================");
System.out.println("Il numero estratto e': "+randomNumber);
//Print the table
for(int i=0;i<90;i++){
if(cout==10){
System.out.println("");
cout=0;
}
if(table[i]==0){
System.out.print("-- ");
}else if(table[i]>9){
System.out.print(table[i]+" ");
}else{
System.out.print(table[i]+" ");
}
cout++;
}
System.out.println("");
System.out.println("========================================================================================================================");
if(c!=89){
System.out.print("Premi invio per continuare ad estrarre: ");
}
keyb.nextLine();
c++;
clearScreen();
}
}
//OUTPUT
//Game end
System.out.println("Gioco terminato.");
}
static boolean randomVerifier(int[]table,int randomNumber){
boolean randomOk=true;
for(int i=0;i<90;i++){
if(table[i]==randomNumber){
randomOk=false;
}
}
return randomOk;
}
static void clearScreen(){
System.out.print("\033[H\033[2J");
}
}