Skip to content

Commit

Permalink
Create LoginActivity.java
Browse files Browse the repository at this point in the history
  • Loading branch information
GlitchBoyopyt authored Feb 28, 2025
1 parent 7d8203b commit 5066c3b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Logging/LoginActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.Scanner;

public class LoginActivity {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("1. Register");
System.out.println("2. Login");
System.out.print("Select option: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline

if (choice == 1) {
System.out.print("Enter username: ");
String username = scanner.nextLine();
System.out.print("Enter password: ");
String password = scanner.nextLine();

if (UserManager.registerUser(username, password)) {
System.out.println("Registration successful!");
} else {
System.out.println("Username already taken.");
}
} else if (choice == 2) {
System.out.print("Enter username: ");
String username = scanner.nextLine();
System.out.print("Enter password: ");
String password = scanner.nextLine();

if (UserManager.loginUser(username, password)) {
String uuid = UserManager.getUserUUID(username);
System.out.println("Login successful! Your UUID: " + uuid);
} else {
System.out.println("Invalid username or password.");
}
} else {
System.out.println("Invalid choice.");
}
}
}

0 comments on commit 5066c3b

Please sign in to comment.