Question

In: Computer Science

Java I'm trying to create a program that replicates a theater ticket reservation system. I have...

Java

I'm trying to create a program that replicates a theater ticket reservation system. I have a Seat class with members row(integer), seat(character) and ticketType(character). Where a ticket type can be 'A' adult, 'C' child, 'S' senior, or '.' recorded as empty. I have a Node generic class that points to other nodes(members): up, Down. Left, Right. It also has a generic payload. Lastly, I have an Auditorium class which is also generic. its member is a First Node<T>.

As you can see, its a linked list of nodes where each node is supposed to be a seat (Node<Seat>). The Auditorium is supposed to be a grid of Seat Nodes that contain the seat information within. This way, I can later use the information to intake customer orders and check availability, recommend a best option if not available, etc.

My problem is I'm having trouble creating an overloaded constructor for the Auditorium class. The current auditorium seating information is held in a text file with text such as:

AA.AA....AAA..AACCSS
..AC.....A.........A
S...........AACCCAAC
.AA...CC.SS.....SSC.
A.A..S...S..A......A

I need to add each seat into a node into the auditorium grid before asking the customer for their order to know seat availability.

I tried creating this LONG constructor, but I think the issue is converting the item of type Seat into an item or generic T ((T)currentSeat). This causes the auditorium to output A as ticket type for EVERY single seat in the auditorium. Could you give advice on how to better create an auditorium through the constructor?


       for(int i = 0 ; i < rows ; i++)
       {
           //System.out.println("row " + i);
           currentRowFromFile = readFile.nextLine();
          
           for (int j = 0; j < columns; j++)
           {
               //System.out.println( "column " + j);
               currentSeat.setRow(i);
               currentSeat.setSeat((char)('A'+ j));
               //System.out.print("seat column ");
               //System.out.println((char)('A'+ j));
               currentSeat.setTicketType(currentRowFromFile.charAt(j));
               if(j == 0 && i == 0)
               {
                   First = new Node<T> ((T)currentSeat);  
                   lastNodeCreated = First;
                   thisRowsFirstElement = First;
                   System.out.println("The node being added for index " + i + " " + j + "has seat type: " + currentSeat.getTicketType());
               }
               if(j == 0 && i!= 0) // new row first element
               {
                   //first column on a different row
                   Node<T>newNodeToInsert = new Node<T>((T)currentSeat);
                   thisRowsFirstElement.setDown(newNodeToInsert);   //move down
                   thisRowsFirstElement.getDown().setUp(thisRowsFirstElement);
                   thisRowsFirstElement = thisRowsFirstElement.getDown(); // now continue on this row
                   lastNodeCreated = thisRowsFirstElement;
                   System.out.println("The node being added for index " + i + " " + j + "has seat type: " + currentSeat.getTicketType());
               }
               else if(i == 0 && j != 0) // top row
               {
                   Node<T> newNodeToInsert = new Node<T>((T)currentSeat);
                   lastNodeCreated.setRight(newNodeToInsert);
                   lastNodeCreated.getRight().setLeft(lastNodeCreated); // <-->
                   lastNodeCreated = lastNodeCreated.getRight();  
                   System.out.println("The node being added for index " + i + " " + j + "has seat type: " + currentSeat.getTicketType());
               }
               else if(i != 0 && j != 0) // not top row or first column
               {
                   Node <T> newNodeToInsert = new Node<T> ((T)currentSeat);
                   lastNodeCreated.setRight(newNodeToInsert);
                   lastNodeCreated.getRight().setLeft(lastNodeCreated);
                   lastNodeCreated.getRight().setUp(lastNodeCreated.getUp().getRight());
                   lastNodeCreated.getUp().getRight().setDown(lastNodeCreated.getRight());
                   lastNodeCreated = lastNodeCreated.getRight();
                   System.out.println("The node being added for index " + i + " " + j + "has seat type: " + currentSeat.getTicketType());
               }
           }
  

Solutions

Expert Solution

// booking system.
Enums :
public enum SeatStatus {
SEAT_BOOKED,
SEAT_NOT_BOOKED;
}
public enum MovieStatus {
Movie_Available,
Movie_NotAvailable;
}
  
public enum MovieType {
ENGLISH,
HINDI;
}
  
public enum SeatType {
NORMAL,
EXECUTIVE,
PREMIUM,
VIP;
}
  
public enum PaymentStatus {
PAID,
UNPAID;
}
  
class User {
  
int userId;
String name;
Date dateOfBirth;
String mobNo;
String emailId;
String sex;
}
  
class Movie {
  
int movieId;
int theaterId;
MovieType movieType;
MovieStatus movieStatus;
}
  
class Theater {
  
int theaterId;
String theaterName;
Adress adress;
  
List<Movie> movies;
float rating;
}
  
class Booking {
int bookingId;
int userId;
int movieId;
List<Movie> bookedSeats;
int amount;
PaymentStatus status_of_payment;
Date booked_date;
Time movie_timing;
}
  
class Address {
  
String city;
String pinCode;
String state;
String streetNo;
String landmark;
}
The above code has classes and attributes only. In the above code, as you can see enums are self-explanatory.
We have users class in which users details are kept.
Theater class in which name of the theater, it’s address and list of movies currently running are kept.
Booking class lets you book the seat in a particular theater. It keeps a reference in Movie, Payment class.


Related Solutions

I want to write this program in java. Write a simple airline ticket reservation program in...
I want to write this program in java. Write a simple airline ticket reservation program in java.The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit...
Java homework problem. This is my hotel reservation system. I'm trying to add a few things...
Java homework problem. This is my hotel reservation system. I'm trying to add a few things to it. You will be changing your Hotel Reservation system to allow a user to serve more rooms and the rooms will be created as objects. For this project you will be modifying the Hotel Reservation system to allow a user to serve more rooms and the rooms will be created as objects. You will be create a Room object that will allow the...
Description: The purpose of the program is to create a Java ticket purchasing program that allows...
Description: The purpose of the program is to create a Java ticket purchasing program that allows for users to log in, purchase tickets, keep records of tickets purchased, and keep information about the user. Program Requirements: The following are the program requirements: Must be fully functioning including registration, log-in, view events, and purchase tickets Tickets should be purchased using “points”, no information should be provided via the user for payment method. Default each user to an allotted number of points...
Bus ticket reservation project in java using class ,inheritance,interface
Bus ticket reservation project in java using class ,inheritance,interface
Write a simple airline ticket reservation program. The program should display a menu with the following...
Write a simple airline ticket reservation program. The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit on the number of flights. Create a linked list...
The source code I have is what i'm trying to fix for the assignment at the...
The source code I have is what i'm trying to fix for the assignment at the bottom. Source Code: #include <iostream> #include <cstdlib> #include <ctime> #include <iomanip> using namespace std; const int NUM_ROWS = 10; const int NUM_COLS = 10; // Setting values in a 10 by 10 array of random integers (1 - 100) // Pre: twoDArray has been declared with row and column size of NUM_COLS // Must have constant integer NUM_COLS declared // rowSize must be less...
I am trying to create a function in JAVA that takes in an ArrayList and sorts...
I am trying to create a function in JAVA that takes in an ArrayList and sorts the values by their distance in miles in increasing order. So the closest (or lowest) value would be first. It does not need to output the values in anyway, but it should return them so they can be output elsewhere. Please try to use the stub class below. The code for the main class is not necessary. I am only really asking for the...
I am trying to create a method in JAVA that takes in an ArrayList and sorts...
I am trying to create a method in JAVA that takes in an ArrayList and sorts it by the requested "amenities" that a property has. So if someone wants a "pool" and "gym" it would show all members of the array that contain a "pool" and "gym". It does not need to output the values in anyway, but it should return them so they can be output elsewhere. Please try to use the stub class below. You can edit it...
I'm trying to make this C++ loan calculator but I can't get the program to output...
I'm trying to make this C++ loan calculator but I can't get the program to output what I need. For instance I know the formula is right and when I enter 100000 1.5 20 as my cin variables I should get 482.55 but I get 1543.31. What am I not seeing as the issue? Also this should cout only 2 decimal places right? I'm not allowed to alter the #include and add any fixed setprecision. This is what I have....
I am trying to create a makefile for the following program in Unix. The C++ program...
I am trying to create a makefile for the following program in Unix. The C++ program I am trying to run is presented here. I was wondering if you could help me create a makefile for the following C++ file in Unix and show screenshots of the process? I am doing this all in blue on putty and not in Ubuntu, so i don't have the luxury of viewing the files on my computer, or I don't know how to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT