Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package text.game;
- import java.util.Scanner;
- public class TextGame {
- static Scanner scan = new Scanner(System.in);
- static class user extends TextGame {
- String username;
- int password;
- String[] notes;
- public user(String username, int password) {
- this.username = username;
- this.password = password;
- }
- }
- static user[] userarr = new user[10];
- static int a = 0;
- public static void newuser() {
- System.out.println("\n\nType the username for this user.");
- String usernameA = scan.nextLine();
- System.out.println("Username is now " + usernameA + ". is this what you want? type 'yes' to proceed, or 'no' to enter username again.");
- if (scan.nextLine().equals("no")) {
- newuser();
- } else {
- System.out.println("\n\n type the password for this user. (numbers only.)");
- int passwordA = scan.nextInt();
- System.out.println("user is " + usernameA + " and password is " + passwordA + ". creating user.");
- userarr[a] = new user(usernameA, passwordA);
- System.out.println("user created!");
- a += 1;
- }
- }
- public static void login() {
- System.out.println("which account do you want to log into? type the name of a user, or type 'list' to view the users signed in.");
- String ch2 = scan.nextLine();
- if (ch2.equals("list")){
- for (int i=0;i<a;i++) {System.out.println(userarr[i].username);}
- }
- }
- public static void main(String[] args) {
- do {
- System.out.println("Welcome to LINCOLN COMP console OS. Type 'new' to create a new user, type 'log' to log in to an existing user, or type 'exit' to leave.\nif you are asked a yes or no question, if you type something other than yes or no, it will default to yes.");
- String ch1 = scan.nextLine();
- switch (ch1) {
- case "new":
- if (a==10) {
- System.out.println("maximum users have been created. type a username to delete that user, type list to list users, or type back to return.");
- String ch3 = scan.nextLine();
- if (ch3.equals("list")) {for (int i=0;i<a;i++) {System.out.println(userarr[i].username);}} else if (ch3.equals("back")) {break;} else {
- for (int i=0;i<a;i++) {if (System.out.println(userarr[i].username).equals(ch3)){System.out.println("text i will add later");}}
- }
- }else {
- System.out.println("Initializing user creation method:");
- newuser();
- }
- break;
- case "log":
- login();
- break;
- case "exit":
- System.out.println("Goodbye!");
- System.exit(0);
- break;
- case "debug":
- for (int i=0;i<userarr.length;i++) {System.out.println(userarr[i]);}
- break;
- default:
- System.out.println("restarting.");
- }
- } while (true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement