Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package UnimapDBConsole;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class executer
- {
- BufferedReader reader;
- String username;
- String password;
- int choice;
- db dbobject;
- public executer()
- {
- reader = new BufferedReader(new InputStreamReader(System.in));
- username = password = null;
- choice=0;
- dbobject = new db();
- dbobject.init();
- login();
- }
- public void login()
- {
- while(true)
- {
- try
- {
- clearScreen();
- System.out.println("Welcome!");
- System.out.println("Enter Username");
- username = reader.readLine();
- System.out.println("Enter Password");
- password = reader.readLine();
- if (dbobject.validate(username, password))
- {
- menu();
- }
- else
- {
- clearScreen();
- System.err.println("Authentication Error");
- }
- //choice = sc.nextInt();
- }
- catch(IOException e)
- {
- System.err.println("Input / Output error");
- }
- catch(NumberFormatException e)
- {
- System.err.println("Please enter the correct input");
- System.out.println();
- menu();
- }
- }
- }
- public void menu()
- {
- do
- {
- clearScreen();
- System.out.println("Welcome!");
- System.out.println("0. Exit");
- System.out.println("1. Add Username");
- System.out.println("2. Add Password");
- System.out.println("3. Add Full Name");
- System.out.println("Please enter your choice: ");
- try
- {
- choice = Integer.parseInt(reader.readLine());
- //choice = sc.nextInt();
- if (choice == 0)
- {
- exit();
- }
- else if (choice == 1)
- {
- //addUsername();
- }
- else if (choice == 2)
- {
- //addPassword();
- }
- else if (choice == 2)
- {
- //addFullname();
- }
- else
- {
- System.out.println("Invalid choice!");
- System.out.println();
- }
- }
- catch(IOException e)
- {
- System.err.println("Input / Output error");
- }
- catch(NumberFormatException e)
- {
- System.err.println("Please enter the correct input");
- System.out.println();
- menu();
- }
- } while(choice != 0);
- }
- public void exit()
- {
- System.out.println("Program exit!");
- }
- public static void clearScreen()
- {
- for (int i=1; i<=10; i++)
- System.out.println("\n");
- }
- public static void main(String[] args)
- {
- // TODO Auto-generated method stub
- db d = new db();
- d.init();
- new executer();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement