Skip to content

Instantly share code, notes, and snippets.

@BlkPingu
Last active October 17, 2018 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlkPingu/936033fd168849bca4f1d478edebd4b6 to your computer and use it in GitHub Desktop.
Save BlkPingu/936033fd168849bca4f1d478edebd4b6 to your computer and use it in GitHub Desktop.
Basic Java Command Line User Interface (CUI)
package userinterface;
import java.util.Scanner;
public class Userinterface{
Scanner scanner = new Scanner(System.in);
boolean done;
public void dialog(){
System.out.println("[1] 1 option");
System.out.println("[2] 2 option");
System.out.println("[3] 3 option");
System.out.println("[4] 4 option");
System.out.println("[5] 5 option");
System.out.println("[6] 6 option");
System.out.println("[7] 7 option");
System.out.println("[8] 8 option");
System.out.println("[9] 9 option");
System.out.println("[10] 10 option");
System.out.println("[11] 11 option");
System.out.println("[12] 12 option");
}
public void run(){
while(!done){
dialog();
System.out.print("Enter (): ");
int choice = scanner.nextInt();
switch(choice) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
break;
case 12:
break;
default:
System.out.println("Incorrect Input.");
break;
}
}
}
}
import userinterface.Userinterface;
public class Main {
public static void main(String[] args) {
Userinterface userinterface = new Userinterface();
userinterface.run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment