import java.util.Scanner;
import java.lang.Math;
public class Menu {
public final String DEFAULT = "\u001B[0m";
public final String[][] COLORS = {
{"Default",DEFAULT},
{"Red", "\u001B[31m"},
{"Green", "\u001B[32m"},
{"Yellow", "\u001B[33m"},
{"Blue", "\u001B[34m"},
{"Purple", "\u001B[35m"},
{"Cyan", "\u001B[36m"},
{"White", "\u001B[37m"},
{"Reset","\u001B[0m"},
{"Liverpool","\033[1;91m"},
{"Tottenham","\033[0;107m"},
{"Real","\033[0;95m"},
{"Bayern","\033[0;101m"},
{"Dortmund", "\033[0;93m"},
};
public final int NAME = 0;
public final int ANSI = 1;
public Menu() {
Scanner sc = new Scanner(System.in);
this.print();
boolean quit = false;
while (!quit) {
try {
int choice = sc.nextInt();
System.out.print("" + choice + ": ");
quit = this.action(choice);
} catch (Exception e) {
sc.nextLine();
System.out.println(e + ": Not a number, try again.");
}
}
sc.close();
}
private void print() {
System.out.println("-------------------------\n");
System.out.println("Soccer Info");
System.out.println("-------------------------\n");
System.out.println("1 - Premier League Scorers");
System.out.println("2 - La Liga Scorers");
System.out.println("3 - Champions Scorers ");
System.out.println("4 - Bundesliga Scorers");
System.out.println("5 - Serie A Scorers");
System.out.println("6 - Goals Against Calculator");
System.out.println("7 - Shooting Percentage Calculator");
System.out.println("0 - Quit");
System.out.println("-------------------------\n");
}
private boolean action(int selection) {
boolean quit = false;
switch (selection) {
case 0:
System.out.print("Program Exiting...");
quit = true;
break;
case 1:
System.out.println(COLORS[4][ANSI] + "Premier League Top Scorers" + COLORS[8][ANSI]);
System.out.println(COLORS[9][ANSI] + "\t Mohamed Salah" + COLORS[8][ANSI]);
System.out.println("\t" + COLORS[10][ANSI] + "Son" + COLORS[8][ANSI]);
System.out.println(COLORS[1][ANSI] + "\t Cristiano Ronaldo" + COLORS[8][ANSI]);
System.out.println("\t" + COLORS[10][ANSI] + "Harry Kane" + COLORS[8][ANSI]);
System.out.println(COLORS[9][ANSI] + "\t Sadio Mane" + COLORS[8][ANSI]);
break;
case 2:
System.out.println(COLORS[1][ANSI] + "La Liga Top Scorers" + COLORS[8][ANSI]);
System.out.println(COLORS[11][ANSI] + "\t Karim Benzema" + COLORS[8][ANSI]);
System.out.println("\t Iago Aspas");
System.out.println("\t Raul de Tomas");
System.out.println(COLORS[11][ANSI] + "\t Vinicius" + COLORS[8][ANSI]);
System.out.println("\t Juanmi");
// for(int i = 0; i < COLORS.length; i++)
// System.out.print(COLORS[i][ANSI] + COLORS[i][NAME]);
break;
case 3:
System.out.println(COLORS[6][ANSI] + "Champions League Top Scorers" + COLORS[8][ANSI]);
System.out.println(COLORS[11][ANSI] + "\t Karim Benzema" + COLORS[8][ANSI]);
System.out.println("\t \u001B[37m" + COLORS[12][ANSI] + "Robert Lewangoalski" + COLORS[8][ANSI]);
System.out.println("\t Sébastien Haller");
System.out.println(COLORS[9][ANSI] + "\t Mohamed Salah" + COLORS[8][ANSI]);
System.out.println("\t Christopher Nkunku");
// for (int i = 0; i < 20; i++) {
// int random = (int) (Math.random() * COLORS.length);
// try {
// Thread.sleep(100);
// } catch (Exception e) {
// System.out.println(e);
// }
// System.out.print(COLORS[random][ANSI] + "#");
// }
break;
case 4:
System.out.println(COLORS[5][ANSI] + "Bundesliga" + COLORS[8][ANSI]);
System.out.println("\t \u001B[37m" + COLORS[12][ANSI] + "Robert Lewangoalski" + COLORS[8][ANSI]);
System.out.println("\t Patrick Schick");
System.out.println("\t \033[0;93m" + COLORS[13][ANSI] + "Erling Haaland" + COLORS[8][ANSI]);
System.out.println("\t Anothny Modeste");
System.out.println("\t Christopher Nkunku");
break;
case 5:
System.out.println(COLORS[2][ANSI] + "Serie A" + COLORS[8][ANSI]);
System.out.println("\t Ciro Immobile");
System.out.println("\t Dušan Vlahović");
System.out.println("\t Lautaro Martínez");
System.out.println("\t Tammy Abraham");
System.out.println("\t Giovanni Simeone");
break;
case 6:
Scanner myObj = new Scanner(System.in);
System.out.println("Enter Goals Against and Games Played:");
int GoalsAgainst = myObj.nextInt();
double GamesPlayed = myObj.nextDouble();
myObj.close();
System.out.println("Goals Against Average: " + GoalsAgainst/GamesPlayed);
case 7:
Scanner newObj = new Scanner(System.in);
System.out.println("Enter Goals Scored and Shots Taken:");
int GoalsScored = newObj.nextInt();
double ShotsTaken = newObj.nextDouble();
newObj.close();
System.out.println("Shooting Percentage: " + GoalsScored/ShotsTaken);
default:
System.out.print("Unexpected choice, try again.");
}
System.out.println(DEFAULT);
return quit;
}
static public void main(String[] args) {
new Menu();
}
}
Menu.main(null);