-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
75 lines (56 loc) · 2.94 KB
/
Main.java
File metadata and controls
75 lines (56 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import controllers.AuthenticationController;
import controllers.PostController;
import controllers.PostService;
import models.User;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Initialize System Components
AuthenticationController authController = new AuthenticationController();
PostService postService = new PostService();
PostController postController = new PostController(postService);
System.out.println("=== Welcome to Campus Connect System ===");
// ---------------------------------------------------------
// Step 1: Registration
// ---------------------------------------------------------
System.out.println("\n--- Step 1: Registration ---");
System.out.print("Enter your Student ID: ");
String regId = scanner.nextLine();
System.out.print("Enter your Full Name: ");
String regName = scanner.nextLine();
System.out.print("Enter your Email: ");
String regEmail = scanner.nextLine();
System.out.print("Create Password: ");
String regPass = scanner.nextLine();
authController.registerUser(regId, regEmail, regPass, regName);
System.out.println("Success: User registered successfully!");
// ---------------------------------------------------------
// Step 2: Login
// ---------------------------------------------------------
System.out.println("\n--- Step 2: Login ---");
System.out.print("Enter Email to Login: ");
String loginEmail = scanner.nextLine();
System.out.print("Enter Password: ");
String loginPass = scanner.nextLine();
User loggedInUser = authController.login(loginEmail, loginPass);
if (loggedInUser != null) {
System.out.println("Login Successful! Welcome " + loggedInUser.getFullName());
// ---------------------------------------------------------
// Step 3: Create Post
// ---------------------------------------------------------
System.out.println("\n--- Step 3: Create Post ---");
System.out.println("What is on your mind?");
String content = scanner.nextLine();
postController.createNewPost(content, loggedInUser);
// ---------------------------------------------------------
// Step 4: View Timeline (Retrieve Data)
// ---------------------------------------------------------
postController.showAllPosts();
} else {
System.out.println("Error: Invalid Email or Password.");
System.out.println("System: Access Denied.");
}
scanner.close();
}
}