Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: In preparation for the release of Guardians of the Galaxy 2, you have b

ID: 3823239 • Letter: P

Question

Problem: In preparation for the release of Guardians of the Galaxy 2, you have been hired by the owner of a small

movie theater to develop the backend for an online ticket reservation system. Patrons will be able to reserve

seats in one of three auditoriums. Once the patron has selected an auditorium, the program should display the

current seating arrangement and allow the patron to select seats. A report should be generated at the end of the

program to specify for each individual auditorium and overall for all auditoriums how many seats were

sold/unsold and how much money was earned.

Classes

Base Node (Abstract)

o Members

Row (integer)

Seat (integer)

o Methods

Overloaded constructor

Mutators

Accessors

DoubleLinkNode (derived)

o Members

Next (DoubleLinkNode pointer)

Prev (DoubleLinkNode pointer)

o Methods

Overloaded constructor

Mutators

Accessors

Linked List (separate class, same package)

o Members

Head (DoubleLinkNode pointer)

Tail (DoubleLinkNode pointer)

o Methods

Overloaded constructor

Takes DoubleLinkNode parameter for head

Assign tail to proper node

Mutators

Accessors

Other methods that are necessary to interact with a linked list

Remember methods should be generic enough to be used on a linked list

regardless of the problem.

o All functions that modify the linked list must be of your own design rather than using built-in

functions of Java libraries

Details

To avoid potential errors when grading, do not create multiple Scanner objects for System.in. If the

Scanner object is needed in multiple functions, please pass the Scanner object into the function.

The seating arrangement for each auditorium will be stored in separate files. These files will be named

A1.txt, A2.txt and A3.txt for auditorium 1, 2 and 3 respectively.

Each line in the file will represent a row in the auditorium. The number of rows in each auditorium is

unknown to you.

The number of seats in each row of a single auditorium will be the same. For example, if the first line of

the file has 15 seats, then every subsequent row in the theater will also have 15 seats. This does not

mean that each auditorium has the same number of seats in each row. One auditorium may have 15

seats per row and another may have 20 seats.

Empty seats are represented by a pound sign (#).

Reserved seats are represented by a period (.).

Each file should be read into memory and stored in a linked list

o For each auditorium, you will have 2 linked lists – one for reserved seats and one for available

seats

o When available seats are reserved, the nodes from the available list should be moved into the

reserved list

o Both lists should be sorted by row and seat number – all row 1 seats grouped together in order by

seat, then row 2, etc.

If the user is reserving seats, ask the user for the number of tickets, the row and seat number of the first

seat. If that seat and all seats to the right of it (up to the number of tickets desired) are available, move

the nodes from the available linked list into the reserved linked list. After seats are reserved, please

display a confirmation of this on the screen.

o If the desired seats are not available, offer the user the best available seats that meet their

criteria in the entire auditorium. The best available seats are the seats closest to the middle of

the auditorium.

Think of the distance between 2 points

For simplicity, use the distance between the first seat of the section and the center.

In the event of a tie for distance, the row closest to the middle of the auditorium should

be selected.

You may develop this piece any way that you see fit. Please try to be as efficient as

possible with the memory.

o State to the user what the best available seats are and then ask if they would like those seats.

o If the user declines the best available seats, return the user to the main menu.

o If the user accepts the best available seats, reserve them and display a conformation to the

screen.

Tickets can only be reserved the day of the screening and all screenings are at 7 PM that night. There is

no need to worry about multiple screenings or reserving seats on a specific day.

All tickets are $7 regardless of patron age or auditorium.

At the end of the program, overwrite the original files with the new information. Use a recursive function

to write the data back to the file. NOTE IN THE COMMENTS AT THE TOP OF YOUR MAIN SOURCE FILE

THE LINE NUMBERS OF THE RECURSIVE FUNCTION CALL AND THE FUNCTION DEFINITION.

User Interface and Input: Present a user-friendly menu system for the user to reserve seats.

1. Reserve Seats

2. View Auditorium

3. Exit

Although in reality the user would likely only make one purchase, for testing purposes, assume the user will

repeat the ticket buying process until they decide to quit.

After the user has selected a non-exit option, present the user with a menu to select the auditorium.

1. Auditorium 1

2. Auditorium 2

3. Auditorium 3

Once the auditorium has been selected, display the current seating availability for that auditorium. An example

seating chart is provided below for an auditorium with 5 rows and 20 seats per row.

12345678901234567890

1 ...##..#####........

2 ########....####..##

3 .........##.........

4 #.#.#.#.#.#.#.#.#.#.

5 ########.#####.#####

The seats are numbered sequentially from left to right and only the ones digit is displayed above each column to

make it easier to display the chart. It is understood that the second set of digits from 1-0 are for the numbers 11-

20 in the above example.

After the user has selected the auditorium and the seating chart has been displayed, prompt the user for the

following information in the order below:

Row number

Starting seat number

Number of tickets

Assume that the user wants to reserve sequential seats to the right of the first seat entered.

If the desired seats are not available, offer the user the best available seats that meet their criteria in the entire

auditorium (see details above). Prompt the user to enter a Y to reserve the best available or N to refuse the best

available. Once the selection has been processed, return to the main menu.

When prompting the user for input, expect anything. Do not assume any input will be valid. If you ask for a

number, the user could put in a floating point number, symbols or maybe even the Gettysburg Address (or at least

a sentence or two). Make sure that your program handles proper validation. If invalid input is entered, loop until

valid input is received. Consider using exception handling for that task (but it is not required)

Output: At the end of the program, write the current status of each auditorium to the proper file. Also display a

formatted report to the console. The report should consist of 4 columns:

Column 1 – labels

o Auditorium 1

o Auditorium 2

o Auditorium 3

o Total

Column 2 - number of seats reserved for each label

Column 3 - the number of open seats for each label

Column 4 - the total of the ticket sales for each label

Explanation / Answer

Below are the code for what you were needing in order to solve your assignment.

Booking Class -------------------
import java.util.*;
import java.io.*;

public abstract class Booking
{
   String date, personID;
   int num;
   char status='b';

public Booking(String dateX, String personIDX, int numX)
{
   date=dateX;
   personID=personIDX;
   num=numX;
}

public String getPersonID()
{
   return personID;
}

public String getDate()
{
   return date;
}

public abstract double getCost();

public double getAmount()
{
   return num;
}

}

Show Class ----------------------------------
import java.util.*;
import java.io.*;

public class Show
{
  
   String showName;
   String showDate;
   double collection;
   int numBookings;
   char[] seatStatus=new char[50];
   int numofseatsRemaining[]=new int[50];
   int[] freeSeats=new int[50];
   Booking[] booking=new Booking[50];
  

public Show( String showNameX, String showDateX)
{
   showDate=showDateX;
   showName=showNameX;
  
   for (int i = 0; i <= 49; i++)
   {
       seatStatus[i]='f';
   }
}
public String getShowName()
{
   return showName;
}
public String getShowDate()
{
   return showDate;
}
public char[] getAllSeatsStatus()
{
   return seatStatus;
}
public Booking[] getAllBookings()
{
   for(int i=0; i<booking.length; i++)
   {
       booking[i].getPersonID();
       booking[i].getDate();
       booking[i].getAmount();
   }
   return booking;
}
public int getNumSeatsRemaining()
{
   int numofseatsRemaining=0;
   for(int j=1; j<=50; j++)
   {
       if(getAllSeatsStatus()[j]=='f')
           numofseatsRemaining++;
   }
   return numofseatsRemaining;
}
public int getNumBookings()
{
   for(int i=0; booking[i]!=null; i++)
   {
       numBookings++;
   }
   return numBookings;
}
public int[]getFreeSeats()
{

   return numofseatsRemaining;
}
public double getCollection()
{
   return collection;
}
public void bookSeats(int seats[])
{
  
}
public boolean addBooking(Booking B)/>
{
   return true;
}
public void addToCollection(double amount)
{
   collection+=amount;
}
  
}


SeatsBooking Class------------------------

import java.util.*;
import java.io.*;
public class SeatsBooking extends Booking
{
   double cost;
   public int[] seats=new int[50];
  

public SeatsBooking(String dateX, String personIDX, int numX, int[] seatsX)
{
   super(dateX,personIDX,numX);
       seats=seatsX;
}

public int[] getSeats()
{
   return seats;  
}

public double getCost()
{
   if (seats.length == 3 || seats.length ==4)
       {
           cost=((seats.length)*20);
           cost=(cost-(cost*10/100));
       //   cost=((seats.length)*20)-((seats.length)*10/100);
       }
   if (seats.length >= 5)
       {
           cost=((seats.length)*20);
           cost=(cost-(cost*20/100));
       //   cost=((seats.length)*20)-((seats.length)*20/100);
       }
      
   return cost;
}

}

SeatsNotFreeException Class--------------------
public class SeatsNotFreeException extends Exception
{
   int[] invalidSeats=new int[50];
   int num;
  
public SeatsNotFreeException(int invalidSeatsX[], int numX)
{
   invalidSeats=invalidSeatsX;
num=numX;    
}
public int[] getInvalidSeats()
{
   return invalidSeats;
}
  
  
}


TheaterManager ---------------Main-------------------
import java.util.*;

public class TheaterManager
{
       public static void main (String[] args)
       {
               int option;
               int option2=0;
               int showcount=0;
               int numofseats=0;
               int numofbook=0;
               int breakcount=0;
               double costing = 0;
               double totalcosting = 0;
               int[] bookcount=new int[50];
               char[] seatStatus = new char[50];
               Show[] shows = new Show[50];
               Booking[] books = new Booking[50];
               String showdate,showname,showdatebook,bookpersonid;
               String confirm,seattype;
               Scanner select = new Scanner(System.in);
               Scanner choice = new Scanner(System.in);
           do
           {  
               System.out.println("------------------------------------");
               System.out.println(" ::Welcome To Theater Manager:: ");
               System.out.println("------------------------------------ ");
               System.out.println("Please Enter 1 to Add Show");
               System.out.println("Please Enter 2 to Display Dates of Shows");
               System.out.println("Please Enter 3 to Make Booking");
               System.out.println("Please Enter 4 to Cancel Booking");
               System.out.println("Please Enter 5 to Confirm Booking");
               System.out.println("Please Enter 6 to Display Collection for a given day");
               System.out.println("Please Enter 7 to Exit ");
      
               System.out.print("Enter Option: ");
                   option = select.nextInt();
                  
                   if(option==1)
                   {
                       System.out.println("Add Show Option Selected");
                       System.out.print("Enter the Date of the Show [DD/MM/YYYY]: ");
                       showdate = choice.nextLine();
                       System.out.print("Enter Name of Show: ");
                       showname = choice.nextLine();
                      
                  
                   shows[showcount] = new Show(showname, showdate);
                   showcount = showcount + 1;
                   }
                   if(option==2)
                   {
                       System.out.println("Display Dates of Shows Selected");
                           for (int i = 0; i<showcount; i++)
                       {
                           System.out.println("Show Name: " + shows[i].showName);
                           System.out.println("Show Date: " + shows[i].showDate);
                          
                           for (int j=0; j<=49; j++)
                           {
                               System.out.print(shows[i].seatStatus[j] + " ");
                              
                           }
                           System.out.println(" ");
                       }
                       System.out.println("End of Show List. ");
                       }
                   if(option==3)
                   {
                       System.out.println("Make Booking Selected");
                           for (int i = 0; i<showcount; i++)
                       {
                           System.out.println("Show Name: " + shows[i].showName);
                           System.out.println("Show Date: " + shows[i].showDate);
                           System.out.print(" ");
                       }
                       System.out.println("End of Show List. ");
                       System.out.print("Shows Available "+showcount);
                       System.out.print(" ");
                       System.out.print("Enter Show Date: ");
                       showdatebook=choice.nextLine();
                      
                       for(int j = 0; j<showcount; j++)
                       {
                           if (showdatebook.equals(shows[j].showDate))
                           {
                               System.out.print("Enter your ID: ");
                               bookpersonid = choice.nextLine();
                               System.out.print("Select your Booking Type:: ");
                               System.out.print("Enter F For Free Booking Or Enter B for Seats Booking::: ");
                               seattype = choice.nextLine();
                              
                               if ((seattype.equals("F")) || (seattype.equals("f")))
                               {
                                   System.out.print("Enter The Number Of Seats To Book: ");
                                   numofseats = select.nextInt();
                                  
                                   for (int k=0; k<50; k++)
                                   {
                                       if (shows[j].seatStatus[k]=='f')
                                       {
                                           shows[j].seatStatus[k]='b';
                                   books[numofbook] = new FreeBooking(showdatebook, bookpersonid, numofseats);
                                           numofbook=numofbook + 1;
                                           breakcount = breakcount + 1;
                                          
                                           if (breakcount==numofseats)
                                           {
                                               breakcount = 0;
                                               break;
                                           }
                                       }
                                   }
                               }
                               else if ((seattype.equals("B")) || (seattype.equals("b")))
                               {
                                   System.out.println("Enter Number Of Seats Required: ");
                                   numofseats = select.nextInt();
                                   int counter=1;
                                   for(int i=0; i<numofseats; i++)
                                   {                      
                                   System.out.println("Enter Seat Number: "+counter);
                                   bookcount[i]=select.nextInt();
                                   counter++;
                                   }
                                  
                                   for(int i=0; i<numofseats; i++)
                                   {
                                   shows[j].seatStatus[(bookcount[i]-1)]='b';
                                   }
                                  
                                   books[numofbook] = new SeatsBooking(showdatebook, bookpersonid, numofbook, bookcount);
                                   numofbook=numofbook + 1;
                               }
                              
                              
                           }
                       }
                      
                       }
                  
                      
                      
                  
                   if(option==4)
                   {
                       System.out.println("Cancel Booking Selected");
                      
                   System.out.print("Enter Show Date: ");
                   showdatebook=choice.nextLine();
                   System.out.print("Enter your ID: ");
                   bookpersonid = choice.nextLine();
                   boolean flag=false;
                   boolean flag1=false;
                  
                   for(int j = 0; j<showcount; j++)
                   {
                       if(shows[j].showDate=="")
                       {
                           break;
                       }
                   if (showdatebook.equals(shows[j].showDate))
                   {
               //       System.out.print("Show Date Found");
                       flag=true;
                   }  
                      
                   }
                  
                   for(int k = 0; k<numofbook; k++)
                   {
                       if(books[k].personID=="")
                       {
                           break;
                       }
                       if (bookpersonid.equals(books[k].personID))
                       {
                       //   System.out.print("Person ID Found");
                           flag1=true;
                   }
                      
                          
                   }
                  
                   if((flag==true)&&(flag1==true))
                   {
                       System.out.print("Do You Want To Confirm: (Y/N)");
                       String confirmdel=choice.nextLine();
                          
                           if((confirmdel=="Y")||(confirmdel=="y"))
                           {
                          
                          
                           System.out.print("Yes Selected");
                          
                              
                           }
                           else if((confirmdel=="N")||(confirmdel=="n"))
                           {
                              
                           }
                   }
                      

                  
                   }
                   if(option==5)
                   {
                       System.out.println("Confirm Booking Selected");
                      
                       System.out.println("Enter User ID:");
                       bookpersonid = choice.nextLine();
                       System.out.print("Enter Show Date: ");
                       showdatebook=choice.nextLine();
                      
                       for(int k=0; k<50; k++)
                       {
                           if((bookpersonid.equals(books[k].personID))&&(showdatebook.equals(books[k].date)))
                           {
                               for(int i=0; i<50; i++)
                               {
                                   if(books[k].seats[i]=="")
                                   {
                                       break;
                                   }
                                   else
                                   {
                                       System.out.print(books[k].seats[i]);
                                   }
                                  
                               }
                           }
                       }


                   for (int i = 0; i <books.length; i++)
                   {
                   if((books[i].personID=="")&&(books[i].date==""))
                       {
                           break;
                       }
                      
                       System.out.print(i + " - " + books[i].personID);
                      
                       if (books[i] instanceof SeatsBooking)
                       {
                           System.out.println(" - SeatsBooking");
                       }
                      
                       else if (books[i] instanceof FreeBooking)
                       {
                           System.out.println(" - FreeBooking");
                       }
                   }
                      
                       System.out.print("Enter Booking which you want to confirm : ");
                       int selection = select.nextInt();
          
                       if (books[selection] instanceof SeatsBooking)
                       {
                           if ((books[selection]).num >= 3 && (books[selection]).num <= 4)
                           {
                               costing = books[selection].num * 18;
                           }
                              
                           else if (books[selection].num >= 5)
                           {
                               costing = books[selection].num * 16;
                           }
                              
                           else
                           {
                               costing = books[selection].num * 20;
                           }
                          
                           for (int k = 0; k <books.length; k++)
                           {
                               if ((books[k].date).equals(shows[k].showDate))
                               {
                                   shows[k].addToCollection(costing);
                               }
                           }
                          
                       }
                       else if (books[selection] instanceof FreeBooking)
                       {
                           costing = books[selection].num * 10;
                          
                           for (int i = 0; i <books.length; i++)
                           {
                               if ((books[i].date).equals(shows[i].showDate))
                               {
                                   shows[i].addToCollection(costing);
                               }
                           }
                       }  
                   }
              
                              
                   if(option==6)
                   {
                   System.out.println("Display Collection for a given day ");
                      
                   for (int i = 0; i <shows.length; i++)
                   {
                       totalcosting = totalcosting + shows[i].getCollection();
                   }
                  
                   System.out.println("The Total Amount Collected is RM " + totalcosting + ".");
               }
                  
                   if(option==7)
                   {
                       System.out.println("Program Exitting");
                       System.out.println("Confirm To Exit (Y/N): ");
                       confirm = choice.nextLine();
                       if((confirm.compareTo("Y")==0)||(confirm.compareTo("y")==0))
                       {
                           option2=1;
                          
                       }
                       else if((confirm.compareTo("n")==0)||(confirm.compareTo("N")==0))
                       {
                           option2=0;
                       }
                       else
                       {
                               System.out.println("Invalid Selection");
                       }
                      
                   }
                       }while(option2==0);
                  
                  
                  
       }
}

Hope this will help .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote