Java Menu (NFL Draft)
A Jupyter Notebook for Java Menus
import java.net.http.*;
import java.util.Scanner;
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("NFL Draft Picks");
System.out.println("<><><><><><><><><><><><><><>\n");
System.out.println("1 - Top Running Backs");
System.out.println("2 - Top Wide Recievers");
System.out.println("3 - Top Tide Ends");
System.out.println("4 - Top Quarterbacks");
System.out.println("5 - Top Defenses");
System.out.println("0 - Quit");
System.out.println("<><><><><><><><><><><><><><>\n");
}
private boolean action(int selection) {
boolean quit = false;
switch (selection) {
case 0:
System.out.print("Exiting Program");
quit = true;
break;
case 1:
System.out.println(COLORS[10][ANSI] + "Top Running Backs" + COLORS[8][ANSI]);
System.out.println(COLORS[1][ANSI] + "\t J. Taylor" + COLORS[8][ANSI]);
System.out.println(COLORS[1][ANSI] + "\t C. McCaffrey" + COLORS[8][ANSI]);
System.out.println(COLORS[1][ANSI] + "\t A. Ekeler" + COLORS[8][ANSI]);
System.out.println(COLORS[1][ANSI] + "\t D. Henry" + COLORS[8][ANSI]);
System.out.println(COLORS[1][ANSI] + "\t D. Cook" + COLORS[8][ANSI]);
break;
case 2:
System.out.println(COLORS[2][ANSI] + "Top Wide Recievers" + COLORS[8][ANSI]);
System.out.println(COLORS[3][ANSI] + "\t J. Jefferson" + COLORS[8][ANSI]);
System.out.println(COLORS[3][ANSI] + "\t C. Kupp" + COLORS[8][ANSI]);
System.out.println(COLORS[3][ANSI] + "\t J. Chase" + COLORS[8][ANSI]);
System.out.println(COLORS[3][ANSI] + "\t S. Diggs" + COLORS[8][ANSI]);
System.out.println(COLORS[3][ANSI] + "\t D. Adams" + COLORS[8][ANSI]);
break;
case 3:
System.out.println(COLORS[4][ANSI] + "Top Tide Ends" + COLORS[8][ANSI]);
System.out.println(COLORS[5][ANSI] + "\t M. Andrews" + COLORS[8][ANSI]);
System.out.println(COLORS[5][ANSI] + "\t K. Pitts" + COLORS[8][ANSI]);
System.out.println(COLORS[5][ANSI] + "\t G. Kittle" + COLORS[8][ANSI]);
System.out.println(COLORS[5][ANSI] + "\t D. Waller" + COLORS[8][ANSI]);
System.out.println(COLORS[5][ANSI] + "\t T. Kelce" + COLORS[8][ANSI]);
break;
case 4:
System.out.println(COLORS[6][ANSI] + "Top Quarterbacks" + COLORS[8][ANSI]);
System.out.println(COLORS[7][ANSI] + "\t J. Allen" + COLORS[8][ANSI]);
System.out.println(COLORS[7][ANSI] + "\t J. Herbert" + COLORS[8][ANSI]);
System.out.println(COLORS[7][ANSI] + "\t L. Jackson" + COLORS[8][ANSI]);
System.out.println(COLORS[7][ANSI] + "\t P. Mahomes" + COLORS[8][ANSI]);
System.out.println(COLORS[7][ANSI] + "\t J. Hurts" + COLORS[8][ANSI]);
break;
case 5:
System.out.println(COLORS[8][ANSI] + "\t Top Defenses" + COLORS[8][ANSI]);
System.out.println(COLORS[9][ANSI] + "\t Bufallo Bills" + COLORS[8][ANSI]);
System.out.println(COLORS[9][ANSI] + "\t Dallas Cowboys" + COLORS[8][ANSI]);
System.out.println(COLORS[9][ANSI] + "\t Tampa Bay Bucaneers" + COLORS[8][ANSI]);
System.out.println(COLORS[9][ANSI] + "\t San Francisco 49ers" + COLORS[8][ANSI]);
break;
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);