Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Menu m = new Menu();
- Scanner in = new Scanner(System.in);
- int option = 0;
- User user = null;
- while (option != 4) {
- if (user == null) {
- System.out.println("Please enter your option:");
- printMenu();
- } else {
- printMenuLoggedIn(user);
- }
- option = in.nextInt();
- switch (option) {
- case 1:
- m.signUp();
- user = null;
- break;
- case 2:
- user = m.login();
- break;
- case 3:
- if (user == null) {
- System.out.println("Bye!");
- option = 4;
- } else {
- m.changePassword(user);
- }
- break;
- case 4:
- System.out.println("Bye!");
- break;
- default:
- System.out.println("Invalid option");
- break;
- }
- }
- }
- //Printing this menu when NO user is logged in.
- public static void printMenu(){
- System.out.println("1. Sign up.");
- System.out.println("2. Log in.");
- System.out.println("3. Exit.");
- }
- //Printing this menu when user IS logged in.
- public static void printMenuLoggedIn(User user){
- System.out.println("Welcome " + user.getUsername() + "!");
- System.out.println("Please enter your option:");
- System.out.println("1. Sign up.");
- System.out.println("2. Log in.");
- System.out.println("3. Change password.");
- System.out.println("4. Exit.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement