Edit
This commit is contained in:
@@ -1,7 +1,91 @@
|
||||
package movie.apis;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
|
||||
private static final MovieService movieService = new MovieService();
|
||||
private static final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO: Receive your data from here
|
||||
System.out.println("\n=== MOVIE API CLIENT ===\n");
|
||||
|
||||
boolean running = true;
|
||||
while (running) {
|
||||
displayMenu();
|
||||
int choice = getIntInput("Enter your choice: ");
|
||||
|
||||
switch (choice) {
|
||||
case 1:
|
||||
movieService.displayGenres();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// TODO: Get genre ID and page from user, then call movieService.displayMoviesByGenre()
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// TODO: Get page number from user, then call movieService.displayAllMovies()
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// TODO (BONUS): Get movie ID from user, then call movieService.displayMovieDetails()
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 0:
|
||||
running = false;
|
||||
System.out.println("Goodbye!");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println("Invalid choice! Please enter 0-4");
|
||||
}
|
||||
|
||||
if (running) {
|
||||
System.out.println("\nPress Enter to continue...");
|
||||
scanner.nextLine();
|
||||
scanner.nextLine();
|
||||
}
|
||||
}
|
||||
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static void displayMenu() {
|
||||
System.out.println("\n================================");
|
||||
System.out.println(" MENU");
|
||||
System.out.println("================================");
|
||||
System.out.println("1. Get all genres");
|
||||
System.out.println("2. Get movies by genre ID");
|
||||
System.out.println("3. Get all movies");
|
||||
System.out.println("4. Get movie details by ID");
|
||||
System.out.println("0. Exit");
|
||||
System.out.println("================================");
|
||||
}
|
||||
|
||||
private static int getIntInput(String prompt) {
|
||||
System.out.print(prompt);
|
||||
while (!scanner.hasNextInt()) {
|
||||
System.out.print("Invalid input. " + prompt);
|
||||
scanner.next();
|
||||
}
|
||||
int input = scanner.nextInt();
|
||||
scanner.nextLine();
|
||||
return input;
|
||||
}
|
||||
|
||||
private static Long getLongInput(String prompt) {
|
||||
System.out.print(prompt);
|
||||
while (!scanner.hasNextLong()) {
|
||||
System.out.print("Invalid input. " + prompt);
|
||||
scanner.next();
|
||||
}
|
||||
Long input = scanner.nextLong();
|
||||
scanner.nextLine();
|
||||
return input;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user