CrazyEngineers
  • Cinema booking system

    dedeltek

    Member

    Updated: Oct 22, 2024
    Views: 927
    Hi there,

    I have a little problem with java,
    I can't find my mistakes if someone can help me to complete it,
    I should submit my work on Monday before 16h

    here is what i've done so far but doesn't want to compile:
    Movie 
    title string
    screen string
    showtime string
    
    
    List <Movie> moviz= new ArrayList<Movie>();
    
    Movie m1= new Movie ("Men In Black", "Screen 10", "13h30,16h00,19h30" );
    Movie m2= new Movie ("Matrixx", "Screen 11", "14h30, 16h30,18h30" );
    Movie m3= new Movie ("Devdas", "Screen 12", "15h30, 18h00, 20h00" );
    Movie m4= new Movie ("Source Code", "Screen 13", "13h30, 15h30, 17h00" );
    Movie m5= new Movie ("Limitless", "Screen 14", "12h30, 15h00, 17h30" );
    
    moviz.add(m1);
    moviz.add(m2);
    moviz.add(m3);
    moviz.add(m4);
    moviz.add(m5);
    
    System.out.println(Movie); // implicity call toString method of List
    
    public String toString()
    {
    return "(" + title +", "+ screen", "+ "showtime +")\n";
    }
    
    --------------------------------------------------------------------------------------
    
    Class Cinema
    {
    
    private String film;
    private STring screener;
    private String showFilm;
    
    
    public Cinema (String filmIn, String screenerIn, String showFilmIn);
    {
    
    film= filmIn;
    screener= screenerIn;
    showFilm= showFilmIn;
    }
    
    
    public String getFilm()
    {
    return film;
    }
    
    
    public String getScreener()
    {
    return screener;
    }
    
    public String getShowFilm()
    {
    return showFilm;
    }
    
    }
    
    --------------------------------------------------------------------------------------------
    
    import java.util.*;
    import java.io.*;
    
    
    public class MovieFileTester
    {
    
    public static void main (String [] args)
    {
    char choice;
    
    List <Movie> moviz= new ArrayList<Movie>();
    readList(moviz);
    
    
    do
    {
    
    System.out.println("\nCinema Tester");
    System.out.println("1. Add movie/seat");
    System.out.println("2. Remove movie/seat");
    System.out.println("3. List all movies");
    System.out.println("4. Quit\n");
    
    choice= EasyScanner.nextChar();
    System.out.println();
    
    switch (choice)
    {
    case '1' : addMovie(moviz); break;
    case '2' : removeMovie (moviz); break; 
    case '3' : listAll (moviz); break;
    case '4' : System.out.print ("\nPlease choose a number form 1 - 4 only \n" );
    }
    }while (choice !='4');
    }
    
    
    private static void addMovie (List<Movie>movieListIn)
    {
    String tempMov;
    String tempScre;
    String tempSho;
    
    System.out.print("Please enter Movie title: ");
    tempMov= EasyScanner.nextString();
    
    System.out.print("Please enter Screen number: ");
    tempScre= EasyScanner.nextString();
    
    System.out.print("Please enter ShowTime: ");
    tempSho= EasyScanner.nextString();
    
    movieListIn.add(new Movie (tempMov, tempScre, tempSho));
    }
    
    
    private static void removeMovie(List<Movie>movieListIn)
     {
    
    int pos;
    System.out.print ("Enter position of the movie to be remove: ");
    pos= EasyScanner.nextInt();
    movieListIn.remove(pos - 1);
    
     }
    
    
    private static void listAll(List<Movie>movieListIn)
     {
    
    for (Movie item : movieListIn)
    System.out.println(item.getFilm() + "" + item.getScreener() + "" + item.getShowFilm());
    
     }
    
    }
    
    
    private static void writerList(List<Movie>movieListIn)
    {
    try
    {
    FileWriter movieFile = new FileWriter("MyShow.txt");
    PrintWriter movieWriter = new PrintWriter (movileFile);
    
    for (Movie Item : movieListIn)
    {
    
    movieWriter.println(item.getFilm());
    movieWriter.println(item.getScreener());
    movieWriter.println(item.getShowFilm());
    }
    movieWriter.close();
    
    }
    
    catch(IOException e)
    {
    System.out.println("There was a problem writing the file");
    }
    
    
    }
    
    private static void readList(List<Movie>movieListIn)
    
    {
    String tempMov;
    String tempScre;
    String tempSho;
    
    try
    {
    
    FileReader movieFile = new FileReader ("MyShow.txt");
    
    BufferedReader movieStream = new BufferedReader(movieFile);
    tempMov=movieStream.readLine();
    while (tempMov !=  null)
    {
    tempScre= movieStream.readLine();
    tempSho= movieStream.readLine();
    movieListIn.add(new Movie (tempMov, tempScre, tempSho));
    tempMov = movieStream.readLine();
    }
    movieStream.close();
    
    }
    
    catch (FileNotFoundException e)
    {
    System.out.println("\nNo file was Read");
    }
    
    catch (IOException e)
    {
    System.out.println("\nThere was a problem reading the file");
    }
    }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Home Channels Search Login Register