-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickNotesApp.java
More file actions
63 lines (49 loc) · 2.16 KB
/
QuickNotesApp.java
File metadata and controls
63 lines (49 loc) · 2.16 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
import java.util.*;
public class QuickNotesApp {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
AuthenticationService authService = new AuthenticationService();
NoteService noteService = new NoteService();
System.out.println("=== Register ===");
System.out.print("Enter username: ");
String username = scanner.nextLine();
System.out.print("Enter password: ");
String password = scanner.nextLine();
System.out.print("Enter email: ");
String email = scanner.nextLine();
User user = new User(1, username, password, email);
boolean registered = authService.registerUser(user);
if (!registered) {
System.out.println("Registration failed. Exiting.");
scanner.close();
return;
}
System.out.println("\n=== Login ===");
System.out.print("Username: ");
String loginUser = scanner.nextLine();
System.out.print("Password: ");
String loginPass = scanner.nextLine();
User loggedInUser = authService.loginUser(loginUser, loginPass);
if (loggedInUser != null) {
System.out.println("Login successful for " + loggedInUser.getUsername());
System.out.print("Enter notebook name: ");
String notebookName = scanner.nextLine();
loggedInUser.createNotebook(notebookName);
Notebook notebook = loggedInUser.getNotebooks().get(0);
System.out.print("Enter note title: ");
String title = scanner.nextLine();
System.out.print("Enter note content: ");
String content = scanner.nextLine();
TextNote note = new TextNote(1, title, content);
note.formatText();
noteService.createNote(notebook, note);
System.out.println("\n--- Notes in " + notebook.getName() + " ---");
for (Note n : notebook.getNotes()) {
n.displayContent();
}
} else {
System.out.println("Login failed.");
}
scanner.close();
}
}