Skip to content

Commit b7f4a37

Browse files
authored
Merge pull request #4 from CodingFactory-Repos/feature/menu
Feature/menu
2 parents 2505ff6 + ee96fc6 commit b7f4a37

File tree

3 files changed

+56
-9
lines changed

3 files changed

+56
-9
lines changed

src/Main.java

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,53 @@
1+
import java.util.Scanner;
2+
13
class Main {
24

35
public static void main(String[] args) {
4-
Player player1 = new Player("Guerrier1", 20.0, 300.0);
5-
System.out.println ("name :"+player1.getName());
6-
player1.setAttack(30);
7-
System.out.println ("vie: "+player1.getHealth()) ;
86

9-
Player player2 = new Player ("Guerrier2", 30., 150.0);
10-
player2.setName("Guerrier2");
11-
player2.damage(player1.getAttack());
12-
System.out.println("puissance d'attaque:"+player2.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+
}
1350

14-
System.out.println (player1.getAttack());
51+
//
1552
}
1653
}

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)