So I am creating a Netflix based simple application, that allows you to add movies into a list and then create playlist, etc. This is the code below
import java.io.IOException; import java.util.Date; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class UserInterface extends Users { public UserInterface(String userName, double accountNumber, Queue<Movie> playList, Queue<Movie> lastMovies) { super(userName, accountNumber, playList, lastMovies); } static LinkedList<Movie> movieDatabase = new LinkedList<Movie>(); public static Scanner keyboard = new Scanner(System.in); public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); while(true){ System.out.println("X) Exit"); System.out.println("0) Create a new movie"); System.out.println("1) Add Movie to your playlist"); System.out.println("2) Upgrade your account"); char c = keyboard.next().charAt(0); switch(c){ case 'X': System.exit(0); case '0': createMovie(); break; case '1': for(int i= 0; i < movieDatabase.size(); i++) { System.out.println(movieDatabase); } break; case '2': System.out.println("Small one time free of $10,000,000!"); break; } } } public static void createMovie() { String password = "adminpassword"; boolean isAdmin = false; double inputPrice = 0; String inputMovie; String inputGenre; Date inputDate = new Date(); String inputPassword; System.out.println("Enter Movie Title:"); inputMovie = keyboard.nextLine(); System.out.println("Enter Movie Genre:"); inputGenre = keyboard.nextLine(); System.out.println("Enter Admin Password Twice:"); inputPassword = keyboard.nextLine(); passCheck(inputPassword, password, isAdmin); adminPower(isAdmin, inputPrice); Movie newMovie = new Movie(inputMovie, inputDate, inputGenre, inputPrice); movieDatabase.add(newMovie); } public static void passCheck(String inputPassword, String password, boolean isAdmin) { if(keyboard.next().equals("adminpassword")) { isAdmin = true; System.out.println("Welcome Administrator"); return; } else System.out.println("Sorry wrong password"); } public static void adminPower(boolean isAdmin, double inputPrice) { isAdmin = true; if (isAdmin == true) { System.out.println("Enter Movie Price:"); inputPrice = keyboard.nextDouble(); } else return; } }
Now where my error is that it won't save the "newMovie" object into the Movie linked list "movieDatabase" it just prints it out as nulls.