Skip to content

Commit ee96fc6

Browse files
committed
✨ - Add Main Menu
1 parent 455b2b7 commit ee96fc6

File tree

3 files changed

+55
-20
lines changed

3 files changed

+55
-20
lines changed

src/Main.java

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,50 @@ class Main {
44

55
public static void main(String[] args) {
66

7-
System.out.println("1 : Menu");
8-
System.out.println("2 : Jouer");
9-
System.out.println("3 : Option");
10-
System.out.println("4 : Quitter");
11-
Scanner sc = new Scanner(System.in);
12-
String jouer = sc.nextLine();
13-
int menu = sc.nextInt();
14-
System.out.println(""+" " +jouer+" "+" "+" "+ menu);
15-
16-
Player player1 = new Player("Guerrier1", 20.0, 300.0);
17-
System.out.println ("name :"+player1.getName());
18-
player1.setAttack(30);
19-
System.out.println ("vie: "+player1.getHealth()) ;
20-
21-
Player player2 = new Player ("Guerrier2", 30., 150.0);
22-
player2.setName("Guerrier2");
23-
player2.damage(player1.getAttack());
24-
System.out.println("puissance d'attaque:"+player2.getAttack());
25-
26-
System.out.println (player1.getAttack());
7+
System.out.print("\033[H\033[2J");
8+
System.out.println("Chargement...");
9+
10+
// Initialize
11+
Scanner scanner = new Scanner(System.in);
12+
13+
// Clear console output
14+
System.out.print("\033[H\033[2J");
15+
16+
String[] titleArray = {" _______ _ _ _____ _ _ ", "|__ __| (_) | | / ____| | | | | ", " | | ___ _ __ _ __ ___ _ _ __ __ _| | | | ___ _ __ ___ | |__ __ _| |_ ", " | |/ _ \\ '__| '_ ` _ \\| | '_ \\ / _` | | | | / _ \\| '_ ` _ \\| '_ \\ / _` | __|", " | | __/ | | | | | | | | | | | | (_| | | | |___| (_) | | | | | | |_) | (_| | | ", " |_|\\___|_| |_| |_| |_|_|_| |_|\\__,_|_| \\_____\\___/|_| |_| |_|_.__/ \\__,_|\\_, | ", ""};
17+
18+
for (String title : titleArray) {
19+
System.out.println(title);
20+
}
21+
22+
String[] menuArray = {"Jouer", "Option", "Quitter"};
23+
24+
for(int i=0; i<menuArray.length; i++){
25+
System.out.println((i + 1) + ": " + menuArray[i]);
26+
}
27+
28+
System.out.print("> ");
29+
30+
switch (scanner.nextInt()) {
31+
case 1:
32+
System.out.println("\n");
33+
Play play = new Play();
34+
play.main();
35+
break;
36+
case 2:
37+
System.out.println("\n");
38+
Options options = new Options();
39+
options.main();
40+
break;
41+
case 3:
42+
System.out.print("\033[H\033[2J");
43+
System.exit(0);
44+
break;
45+
default:
46+
System.out.println("\n");
47+
System.out.println("Erreur");
48+
break;
49+
}
50+
51+
//
2752
}
2853
}

src/Options.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Options {
2+
public void main() {
3+
System.out.println("Options");
4+
}
5+
}

src/Play.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Play {
2+
public void main() {
3+
System.out.println("Play");
4+
}
5+
}

0 commit comments

Comments
 (0)