Closed KouroshKSH closed 9 months ago
DatabaseHandler
To Do:
User
UserInteraction
User
DatabaseHandler
to check user's existence (given a username to check within the DB) and also said user's password (if it matches the saved password for that user in the DB)To Do:
UserInteraction
In user interaction:
// in UserInteractionHandler.java
// in signUp()
DatabaseHandler dbHandler = new DatabaseHandler();
System.out.println("\n> Printing a list 4 of random repositories:\n");
List<Document> result = dbHandler.getRandomRepositories(4);
dbHandler.printRepositories(result);
System.out.println("\n> Printing the list of repositories that have more than 100'000 stars:\n");
result = dbHandler.filterReposWithStarsGEQ(100000);
dbHandler.printRepositories(result);
System.out.println("\n> Let's see if `awesome-neovim` exists in the database. If so, print its information.\n");
result = dbHandler.findRepoByTitle("awesome-neovim");
dbHandler.printRepositories(result);
System.out.println("\n> Let's see if `lazygit` exists in the database. If so, print its information.\n");
result = dbHandler.findRepoByTitle("lazygit");
dbHandler.printRepositories(result);
Task
Implement a basic back-and-forth interaction between the user and the app via the terminal. The user will be asked to either:
Based on the user's choice:
Structure
User Class:
Database Handler:
Main Class:
Steps to Implement
User Class:
User
class with attributes likeusername
,password
, etc.Database Handler:
DatabaseHandler
, for instance) to handle interactions with MongoDB using appropriate libraries (like Spring Data MongoDB).Main Class:
MainClass
, for example).User
andDatabaseHandler
classes.Scanner
to get user input from the terminal and provide choices for sign-up or login.User
class to handle user-related operations (sign-up, login) and methods from theDatabaseHandler
class to interact with the database.Code Skeleton
Here's a basic skeleton of how the classes might look:
This structure provides a basic outline to implement user sign-up, login, and interaction with the database. It's essential to add MongoDB connection setup, handle exceptions, and implement user input validation as needed. Each class is responsible for a specific set of functionalities, ensuring a clean and maintainable codebase.