Skip to content
This repository was archived by the owner on May 18, 2025. It is now read-only.

Commit 5066c3b

Browse files
Create LoginActivity.java
1 parent 7d8203b commit 5066c3b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Logging/LoginActivity.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.util.Scanner;
2+
3+
public class LoginActivity {
4+
public static void main(String[] args) {
5+
Scanner scanner = new Scanner(System.in);
6+
7+
System.out.println("1. Register");
8+
System.out.println("2. Login");
9+
System.out.print("Select option: ");
10+
int choice = scanner.nextInt();
11+
scanner.nextLine(); // Consume newline
12+
13+
if (choice == 1) {
14+
System.out.print("Enter username: ");
15+
String username = scanner.nextLine();
16+
System.out.print("Enter password: ");
17+
String password = scanner.nextLine();
18+
19+
if (UserManager.registerUser(username, password)) {
20+
System.out.println("Registration successful!");
21+
} else {
22+
System.out.println("Username already taken.");
23+
}
24+
} else if (choice == 2) {
25+
System.out.print("Enter username: ");
26+
String username = scanner.nextLine();
27+
System.out.print("Enter password: ");
28+
String password = scanner.nextLine();
29+
30+
if (UserManager.loginUser(username, password)) {
31+
String uuid = UserManager.getUserUUID(username);
32+
System.out.println("Login successful! Your UUID: " + uuid);
33+
} else {
34+
System.out.println("Invalid username or password.");
35+
}
36+
} else {
37+
System.out.println("Invalid choice.");
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)