import java.util.Scanner;
public class MenuAdmin {
public static void main(String[] args) {
Scanner wasdqe = new Scanner(System.in);
String greeting = "Welcome to the Admin Panel of Salam Bro Fast Food Station!\nHere you can do the following activites:";
System.out.println(greeting);
String changedGreeting="";
String basicMenu = "";
String subMenu = "";
int length = 0;
String[][] arrsubMenu = new String[125][125];
String[][] arrPrice = new String[125][125];
for (int i = 0; i < arrPrice.length; i++) {
for (int j = 0; j < arrPrice[i].length; j++) {
arrPrice[i][j] = "0";
}
}
boolean sss = true;
do{
System.out.println("\n0. Exit.");System.out.println("1. Change Welcome Message.");
System.out.println("2. Change Menu.");
System.out.println("3. Change SubMenu.");
System.out.println("4. Change Prices.");
System.out.println("5. Display Welcome Message.");
System.out.println("6. Display Menu.");
System.out.println("7. Display SubMenu.");
System.out.println("8. Display Prices");
System.out.println("9. Switch to client mode(Coming soon).");
System.out.print("\nChoose an activity: ");
int Menuchoose = wasdqe.nextInt();
if (Menuchoose == 0)
break;
switch (Menuchoose){
case 1:
System.out.println("Please, type the message that clients will see when they enter the menu:");
System.out.println("Tip: use underscore (_) as a splitter");
System.out.print(">");
wasdqe.nextLine();
String tmp_Welcome=wasdqe.nextLine();
tmp_Welcome=tmp_Welcome.replaceAll("_", "\n");
changedGreeting=tmp_Welcome;
continue;
case 2:
System.out.println("\nHere you can do the following activities:\n0. Go Back");System.out.println("1. Add categories");System.out.println("2. Remove categories");
int choosemenusetting = wasdqe.nextInt();
if (choosemenusetting==0) continue;
if(choosemenusetting==1){
System.out.println("\nWrite the names of categories separated by coma (c1, c2, ...)");
if (basicMenu != ("")) {
basicMenu += ", ";
}
wasdqe.nextLine();
String putCtgs1 = wasdqe.nextLine();
basicMenu += putCtgs1;
}
if(choosemenusetting==2){
if (basicMenu.equals("")){
System.out.println("\nYou don't have a menu yet");
}
else {
String[] showMenu = basicMenu.split(", ");
for(int i = 0; i < showMenu.length; i++) {
System.out.print((i + 1) + ".");
System.out.println(" " + showMenu[i] + ".");
}
String sqs = "";
int vybor_Menu = wasdqe.nextInt();
String[] arr = basicMenu.split(", ");
if (arr.length == vybor_Menu) {
sqs = basicMenu.replaceAll(arr[vybor_Menu - 1], "");
} else {
sqs = basicMenu.replaceAll(arr[vybor_Menu - 1] + ", ", "");
}
basicMenu = sqs;
}
}continue;
case 3:
String[] menu = basicMenu.split(", ");
System.out.println("\nHere you can do the following activities:");
System.out.println("0. Go Back.");System.out.println("1. Add subcategories.");
System.out.println("2. Remove subcategories.");
System.out.print(">");
int choosesubmenvyibor = wasdqe.nextInt();
if(choosesubmenvyibor==0) continue;
if(choosesubmenvyibor == 1) {
if(basicMenu.equals("")){
System.out.println("\nYou don't have a menu yet");
}
else {
for (int i = 0; i < menu.length; i++) {
System.out.println((i + 1) + "." + " " + menu[i] + ".");
}
int choosesubmenvyibor1 = wasdqe.nextInt();
System.out.println("Write the name of subcategories separated by comma (j1, j2, ...)");
System.out.print(">");
wasdqe.nextLine();
subMenu = wasdqe.nextLine();
String[] subarr = subMenu.split(", ");
length = subarr.length;
for (int i = 0; i < subarr.length; i++) {
int j = choosesubmenvyibor1 - 1;
arrsubMenu[j][i] = subarr[i];
}
}
}
if(choosesubmenvyibor == 2) {
if (basicMenu.equals("")) {
System.out.println("\nYou don't have a menu yet");
} else {
for (int i = 0; i < menu.length; i++) {
System.out.println((i + 1) + "." + " " + menu[i] + ".");
}
int choose2 = wasdqe.nextInt();
if (arrsubMenu[choose2 - 1][0] == null) {
System.out.println("\nYou don't have a subcategory in this category");
} else {
for (int i = 0; i < length; i++) {
int j = choose2 - 1;
System.out.println((i + 1) + "." + " "+ arrsubMenu[j][i]+".");
}
int choosesubmenvyibor2 = wasdqe.nextInt();
String newsub = subMenu.replaceAll(arrsubMenu[choose2 - 1][choosesubmenvyibor2 - 1], "");
subMenu = newsub;
}
}
}continue;
case 4:
if(basicMenu.equals("")){
System.out.println("\nYou don't have a menu yet");
}
else {
System.out.println("Choose a category for which you want to change prices of subcategories:");
String[] menu1 = basicMenu.split(", ");
for (int i = 0; i < menu1.length; i++) {
System.out.print((i + 1) + ".");
System.out.println(" " + menu1[i] + ".");
}
int choose1 = wasdqe.nextInt();
if (arrsubMenu[choose1 - 1][0] == null) {
System.out.println("\nYou don't have a subcategory in this category");
continue;
}
String [] arrsub = subMenu.split(", ");
for (int i = 0; i < arrsub.length; i++) {
int j = choose1 - 1;
System.out.println((i + 1) + "." + " " + arrsubMenu[j][i] + " " + arrPrice[j][i] + "kzt" + ".");
}
System.out.println("Tip: write the indexes separated by comma (i1, i2, ...)");
wasdqe.nextLine();
String pricemenu = wasdqe.nextLine();
String[] massivpricemenu = pricemenu.split(", ");
for (int i = 0; i < massivpricemenu.length; i++) {
int j = choose1 - 1;
arrPrice[i][j] = massivpricemenu[i];
}
}
continue;
case 5:
if(changedGreeting==("")) {
System.out.println("\nYou don't have menu yet!");
}
System.out.println(changedGreeting);
continue;
case 6:
if (basicMenu.equals("")){
System.out.println("\nYou don't have a menu yet");
}
else {
String[] makemenu = basicMenu.split(", ");
if (basicMenu.equals(" ")) System.out.println("\nYou don't have a menu yet");
else {
for (int i = 0; i < makemenu.length; i++) {
System.out.print((i + 1) + ".");
System.out.println(" " + makemenu[i] + ".");
}
}
}
continue;
case 7:
if(basicMenu.equals("")){
System.out.println("\nYou don't have a menu yet");
}
else {
System.out.println();
System.out.println("Choose the category for which you want to see its subcategories:");
System.out.print(">");
String[] adds = basicMenu.split(", ");
for (int i = 0; i < adds.length; i++) {
System.out.print((i + 1) + ".");
System.out.println(" " + adds[i] + ".");
}//menu
int r = wasdqe.nextInt();
if (arrsubMenu[r-1][0] == null) {
System.out.println("\nYou don't have a subcategory in this category");
break;
}
String[] massSubmenu = subMenu.split(", ");
length = massSubmenu.length;
for (int i = 0; i < length; i++) {
int j = r - 1;
System.out.println((i + 1) + "." + " " + arrsubMenu[j][i] + ".");
}
}
continue;
case 8:
if (basicMenu.equals("")) {
System.out.println("\nYou don't have a menu yet");
}
else {
String[] menumassiv = basicMenu.split(", ");
String[] massiv = subMenu.split(", ");
for (int i = 0; i < menumassiv.length; i++) {
System.out.print((i + 1) + ".");
System.out.println(" " + menumassiv[i] + ".");
}
int ss = wasdqe.nextInt();
if(arrsubMenu[ss-1][0] == null){
System.out.println("\nYou don't have subcategory in this category");
}
for (int i = 0; i < massiv.length; i++) {
int j = ss - 1;
System.out.println((i + 1) + "." + " " + arrsubMenu[j][i] + " " + arrPrice[i][j] + "kzt" + ".");
}
}
}
}while (sss);
}
}