Hey I have this java code for a Cinema Booking system that allows customers to print a movie Tickets can someone help me to Add a simple Gui onto this Booking: public class Booking { int cost;...




Hey I have this java code for a Cinema Booking system that allows customers to print a movie Tickets can someone help me to Add a simple Gui onto this


Booking:


public class Booking {


int cost;


Customer costumer;


Show show;


int rowNumber;


int seatNumber;


public Booking(Customer costumer, Show show)


{


this.costumer = costumer;


this.show = show;


}


public int getCost()


{


if(show.getTheatre().getRows().get(rowNumber).getRowClass() == 1) {


return cost += 8;


}


else {


return cost += 5;


}


}


public void setRowNumber(int rowNumber)


{


this.rowNumber = rowNumber;


}


public void setSeatNumber(int seatNumber)


{


this.seatNumber = seatNumber;


}


public boolean reserveSeat(int selectedRow, int selectedSeat)


{


if (show.getTheatre().getRows().get(selectedRow).getSeats().get(selectedSeat).getReservationStatus())


{


return false;


}


else {


show.getTheatre().getRows().get(selectedRow).getSeats().get(selectedSeat).reserve();


setRowNumber(selectedRow);


setSeatNumber(selectedSeat);


return true;


}


}


public boolean unreserveSeat()


{


show.getTheatre().getRows().get(rowNumber).getSeats().get(seatNumber).unreserve();


return true;


}


public Customer getCostumer()


{


return costumer;


}


}



Main Function Cinema:


import java.util.*;


public class Cinema


{


public static void main (String[] args)


{


int option = 0;


ArrayListshows = new ArrayList();


ArrayList theatres = new ArrayList();


ArrayList bookings = new ArrayList();


ArrayList customers = new ArrayList();


Scanner select = new Scanner(System.in);


Scanner choice = new Scanner(System.in);


//Test Objects


Theatre testTheatre = new Theatre(1, "Sheikh's Theatre");


testTheatre.createRows(1, 10, 7);


theatres.add(testTheatre);


shows.add(new Show("The Avengers Age of Ultron - Film","Show Date: 05/04/2018 Genre: Action/Adventure", theatres.get(0)));


shows.add(new Show("The Avengers Infinity - Film", "Show Date: 05/04/2018 Genre: Actiom/Adventure", theatres.get(0)));


shows.add(new Show("Troy - Film", "Show Date: 05/04/2018 Genre: Action/Thriller", theatres.get(0)));


shows.add(new Show("Interstelllar - Film", "Show Date: 05/04/2018 Genre: Space/Thriller", theatres.get(0)));


shows.add(new Show("Lego Movie - Film", "Show Date: 05/04/2018 Genre: Kids/Adeventure", theatres.get(0)));


do


{


System.out.println("------------------------------------");


System.out.println("Cinema Booking System ");


System.out.println("------------------------------------\n");


System.out.println("Please Enter 1 to Add Theatre");


System.out.println("Please Enter 2 to Add Show");


System.out.println("Please Enter 3 to Display Shows");


System.out.println("Please Enter 4 to Make Booking");


System.out.println("Please Enter 5 to Cancel Booking");


System.out.println("Please Enter 6 to Exit\n");


System.out.print("Enter Option: ");


option = select.nextInt();


if(option==1)


{


System.out.println("ADD THEATRE Selected");


System.out.println("-------------------------\n");


System.out.print("Enter a name for the theatre: \n");


String theatreName = choice.nextLine();


System.out.print("Enter a number for the theatre: \n");


int theatreNumber = choice.nextInt();


System.out.println("Enter the number of rows:");


int rowCount = choice.nextInt();


Theatre theatre = new Theatre(theatreNumber, theatreName);


theatre.createRows(1, 10, rowCount);


theatre.createRows(1, 5, 5);


theatres.add(theatre);


}


if(option==2)


{


System.out.println("ADD SHOW Selected");


System.out.println("-------------------------\n");


System.out.println("Enter the date of the Show [DD/MM/YYYY]:");


String showDate = choice.nextLine();


System.out.print("Enter name of Show: \n");


String showName = choice.nextLine();


System.out.println("Select a theatre by typing the number:");


for (int i=0; i <>


{


System.out.println(i+1 + " " + theatres.get(i).getDescription());


}


int theatreNumber = choice.nextInt();


shows.add(new Show(showName, showDate, theatres.get(theatreNumber-1)));


}


if(option==3)


{


System.out.println("DISPLAY SHOWS Selected");


System.out.println("-------------------------\n");


for (int i = 0; i <>


{


int showNumber = i+1;


System.out.println("Show Number: " + showNumber);;


System.out.println("Show Name: " + shows.get(i).getShowName());


System.out.println("Show Date: " + shows.get(i).getShowDate());


//System.out.println("Seat Status:" + shows.get(i).getFreeSeatsCount());


System.out.println("\n");


}


System.out.println("End of Show List.\n");


}


if(option==4)


{


System.out.println("MAKE BOOKING Selected");


System.out.println("-------------------------\n");


Random rnd = new Random();


int costumerId = rnd.nextInt(999);


Customer customer = new Customer(costumerId);


customers.add(customer);


for (int i = 0; i<>


{


int showNumber = i+1;


System.out.println("Show Number: " + showNumber);;


System.out.println("Show Name: " + shows.get(i).getShowName());


System.out.println("Show Date: " + shows.get(i).getShowDate());


System.out.print("\n");


}


System.out.println("-------------------------");


System.out.print("Enter the show number: ");


int showNumber = choice.nextInt();


int repeat = 0;


System.out.println();


do {


shows.get(showNumber-1).getTheatre().printSeatPlan();


System.out.print("Enter the row: ");


int selectedRow = choice.nextInt();


System.out.print("Enter the seat: ");


int selectedSeat = choice.nextInt();


System.out.println();


Booking booking = new Booking(customer, shows.get(showNumber-1));


if (booking.reserveSeat(selectedRow-1, selectedSeat-1)) {


bookings.add(booking);


System.out.println("The seat is now reserved for you.");


}


else {


System.out.println("Sorry the seat is already reserved.");


}


System.out.println();


System.out.print("Enter 1 to reserve another seat or 2 to check out: ");


repeat = choice.nextInt();


} while (repeat == 1);


System.out.println();


System.out.println("Your Bill");


System.out.println("-------------------------");


int totalCost = 0;


for (Booking booking : bookings)


{


if (booking.getCostumer().getId() == customer.getId())


{


totalCost += booking.getCost();


}


}


System.out.println("Costumer ID: " + customer.getId());


System.out.println("Total costs: " + totalCost + " Euro");


System.out.println();


}


if(option==5)


{


System.out.println("CANCEL BOOKING Selected");


System.out.println("-------------------------\n");


System.out.print("Enter the costumer id: ");


int customerId = choice.nextInt();


for (Customer customer : customers) {


if (customer.getId() == customerId)


{


for(Booking booking : bookings)


{


if (booking.getCostumer().getId() == customer.getId())


{


if (booking.unreserveSeat())


{


}


}


}


System.out.println("Your reservation has been canceled!");


}


}


System.out.println();


}


if(option==6)


{


System.exit(0);


}


}while(true);


}


}



Customer:


public class Customer {


int id;


String name;


String surname;


String street;


int streetNumber;


int plz;


String city;


public Customer(int id)


{


this.id = id;


}


public int getId()


{


return id;


}


public void setName(String name)


{


this.name = name;


}


public void setSurname(String surname)


{


this.surname = surname;


}


public void setStreet(String street)


{


this.street = street;


}


public void setStreetNumber(int streetNumber)


{


this.streetNumber = streetNumber;


}


public void setPLZ(int plz)


{


this.plz = plz;


}


public void setCity(String city)


{


this.city = city;


}


public void printCostumer()


{


System.out.print(surname + " " + name);


System.out.println(street + " " + streetNumber);


System.out.println(plz + " " + city);


}


}



Row:


import java.util.*;


public class Row {


private ArrayList seats;


private int rowNumber;


private int rowClass;


private int seatCount;


public Row (int rowClass, int seatCount, int rowNumber)


{


this.rowNumber = rowNumber;


this.rowClass = rowClass;


this.seatCount = seatCount;


seats = new ArrayList();


createSeats(this.seatCount);


}


public void setRowClass(int rowClass)


{


this.rowClass = rowClass;


}


public int getRowClass()


{


return this.rowClass;


}


public int getRowNumber()


{


return rowNumber;


}


public void createSeats(int seatCount)


{


for (int i = 1; i <=>


{


seats.add(new Seat(false, i));


}


}


public ArrayList getSeats()


{


return seats;


}


}



Seat:


public class Seat {


int seatNumber;


boolean isReserved;


public Seat(boolean isReserved, int seatNumber)


{


this.isReserved = isReserved;


this.seatNumber = seatNumber;


}


public void setSeatNumber(int seatNumber)


{


this.seatNumber = seatNumber;


}


public int getSeatNumber()


{


return this.seatNumber;


}


public boolean getReservationStatus()


{


return isReserved;


}


public void reserve()


{


isReserved = true;


}


public void unreserve()


{


isReserved = false;


}


}


import java.util.*;


public class Show {


private String showName;


private String showDate;


private Theatre theatre;


private ArrayList seats;


private int freeSeats;


public Show(String showName, String showDate, Theatre theatre)


{


this.showName = showName;


this.showDate = showDate;


this.theatre = theatre;


}


public void loadSeats()


{


for (Row row : theatre.getRows())


{


for (Seat seat : row.getSeats())


{


seats.add(seat);


}


}


}


public int getFreeSeatsCount()


{


for (Seat seat : seats)


{


if (!seat.getReservationStatus())


{


freeSeats++;


}


}


return freeSeats;


}


public void setShowName(String showName)


{


this.showName = showName;


}


public void setShowDate(String showDate)


{


this.showDate = showDate;


}


public void setTheatre(Theatre theatre)


{


this.theatre = theatre;


}


public String getShowName()


{


return showName;


}


public String getShowDate()


{


return showDate;


}


public Theatre getTheatre()


{


return theatre;


}


public ArrayList getSeats()


{


return seats;


}


}



Theatre:


import java.util.*;


public class Theatre {


private int theatreNumber;


private String description;


private int rowCount;


private ArrayList rows;


public Theatre (int theatreNumber, String description)


{


this.description = description;


this.theatreNumber = theatreNumber;


rows = new ArrayList();


}


public void createRows(int rowClass, int seatCount, int rowCount)


{


for (int i = 1; i <=>


{


rows.add(new Row(rowClass, seatCount, i));


}


this.rowCount += rowCount;


}


public ArrayList getRows()


{


return rows;


}


public String getDescription()


{


return description;


}


public void printSeatPlan()


{


System.out.println();


int maxSeatsInRow = 0;


for (Row row : getRows())


{


if (row.getSeats().size() > maxSeatsInRow)


{


maxSeatsInRow = row.getSeats().size();


}


}


System.out.print(" |");


for (int i=1; i <=>


{


System.out.print(" " + i);


}


System.out.print("\n");


System.out.print("----");


for (int i=1; i <=>


{


if (i>9) {


System.out.print("---");


}


else {


System.out.print("--");


}


}


System.out.print("\n");


for (Row row : getRows())


{


if (row.getRowNumber()>9) {


System.out.print(row.getRowNumber() + " | ");


}


else {


System.out.print(row.getRowNumber() + " | ");


}


for (Seat seat : row.getSeats())


{


if (seat.getReservationStatus()) {


System.out.print("X ");


}


else {


System.out.print(seat.getSeatNumber() + " ");


}


}


System.out.print("\n");


}


System.out.print("\n");


}



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here