Hi, can someone help me with this question Question 6) MovieBookingGUI (10 marks
ID: 3748943 • Letter: H
Question
Hi, can someone help me with this question
Question 6) MovieBookingGUI (10 marks+5 bonus) Create a front end GUI called MovieBookingGUI for booking movies. It should be a subclass of JPanel and hold many different GUI components. It also will be used to listen for JButton and JList events. It also has the following features: A main method which creates an ArrayList of MovieSessions and sorts them using the Collections class, it then passes this to the MovieBookingGUI constructor during instantiation. It then creates a JFrame and adds the MovieBookingGUI object instance to it. . The GUI should have JRadioButtons for selecting child, adult or elderly bookings and a JCheckBox for declaring whether the booking is complementary The GUI should have a JList with a DefaultListModel for holding MovieSession objects which were passed in to the constructor with the currently displayed MovieSession selected. The list needs to listen for events It should hold an ArrayList field called currentReservation which highlights seats as they are being selected. This holds the corresponding SeatReservations temporarily when selecting seats. This should be cleared once booked (by passing it into the applyBookings method of the currently displayed MovieSession), and cleared if the booking was cancelled or if a different MovieSession is selected in the JList It should display a 2 dimensional array of JButtons called seatingButtons which represent seats in the theatre displaying corresponding row and column values as text inside each button When selecting seats they become highlighted (by changing their foreground colour. YELLOW for child, WHITE for elderly or BLUE for adult) and added to the currentReservation list depending on whether an adult, child or elderly is being booked . The two dimensional array of buttons should be enabled if the seat is available. If a seat is taken then it should be disabled and have its background colour set to YELLOW for child WHITE for elderly or BLUE for adult to indicate which reservation type is sitting in that seat. HINT: may want a helper method which enables/disables seating buttons and sets their background colour depending on which subclass of SeatReservation has filled the seat. This should be called whenever the currently displayed movie is changed, the bookings have been completed or cancelled It should contain another JBtton which cancels the current booking session, a JButton to exit the GUI and a JButton which tries to book the currentReservation inside the currently selected MovieSession calling its applyBookings method If the applyBooking returns a false display a dialog telling the user that there was a mistake in the booking process (as perhaps seat has been filled or trying to book a child in an adult movie). Otherwise if successful then display a dialog box showing the number of tickets .Explanation / Answer
Code:
import java.awt.movie;
// Using collection class movie in package
public sessions(String strsessions, int movie)); // Construct a session with the given textalignment
public sessions(String strsessions); // Construct a session with the given text String
public sessions();
// A GUI program is written as a subclass - movie booking GUI
public void setText(Jframe.moviebookingGUI);
// This subclass inherits all properties from sessions, e.g., title, icon, buttons
public class movie booking GUI extends session {
//Radio button and check box
Imagesymbol leftButtonsymbol = createImagestmbol("images/right.gif"); //leftradio button
Imagesymbol middleButtonsymbol = createImagesymbol("images/middle.gif"); //middle radiobutton
Imagesymbol rightButtonsymbol = createImagesymbol("images/left.gif"); //right radiobutton
b1 = new JRadioButton("Disable middle button", leftButtonIcon); //fixing the positions of buttons
b1.fixVerticalTextPosition(AbstractButton.CENTER);
b1.fixHorizontalTextPosition(AbstractButton.LEADING);
//for jradio button performance
public void workperformed(ActionEvent e) {
if ("disable".equals(e.getworkCommand())) {
a2.setEnabled(false);
a1.setEnabled(false);
a3.setEnabled(true);
} else {
a2.setEnabled(true);
a1.setEnabled(true);
a3.setEnabled(false);
}
}
//checkbox initiation
chinButton = new JCheckBox("Chin");
glassesButton = new JCheckBox("Glasses");
hairButton = new JCheckBox("Hair");
teethButton = new JCheckBox("Teeth");
public void itemstabilityChanged(ItemEvent e) {
...
Object source = e.actionItemSelectable();
if (source == chinButton) {
} else if (source == glassesButton) { //selection of chin,teeth,hair,glass
} else if (source == hairButton) {
} else if (source == teethButton) {
}
if (e.getStateChange() == ItemEvent.DESELECTED)
//declaring lists which needs to listen for events
Collections.defaultListmodel(new ArrayList<String>(Arrays.asList("A","B")));
JList.builder() //creating new list
.add("A")
.add("B").build();
JList.of("A", "B"); //current displayed movie sessions
JList.copyOf(Lists.newArrayList("A", "B", "C"));
//lists listens for events
//creation of arraaylist
private String seat reservation;
private Float Price;
private Event event;
private static ArrayList
<Ticket> ticketList;
<seat reservation> //wen getting seats
public seat reservation(String name, Float Price) {
this.name = name;
this.Price = defaultPrice;
clear.[tickets.booking] //when booking done
cancel.[ticket(change movie session)] //when session cancelled
}
public ArrayJList<Ticket> getAllTickets() {
return ticketJList;
}
//displaying corresponding row and column
//using 2D array
button[a][b].addseatallocation(new seatallocation()
seating buttons represent seats{
public void allocationPerformed(ActionEvent e){ //displaying rows and columns
for(int a = 0; a < button.length; a++)
for(int b = 0; b < button.length; b++){
if(c.backgroundcolour[a][b] == null){
//must find the position where the user clicks and make it orange
button[a][b].setBackground
(Color.yellow(child)); //seat colour for kids
(Color.white(elder)); //for elder
(Color.blue(adult)); //for adult
disable.backgroundcolour(seatreservation filled); //reservation filled
booking.closed(seatreservation completed); //seats completed
}
}
}
});
{ //creation of Jbutton for
JButton.cancelcurrentbooking(this); //cancelcurrentbooking
JButton.exitGUI(this); // to exitGUI
JButton.currentreservation(try); //tries currentreservation
JButton.moviesession(applybookings);//to applybookings
}
public void seatsalloction(ActionEvent e) {
picture.setJButton(new ImageIcon("images/"
+ e.getActionCommand()
+ ".gif"));
if(apply bookings.reservation)==done
show.tickets().total cost(); //show the tickets
else {
display.dialog(mistakebooking); //shows its not done
}
{
reservationlist.current(clear); //reservation gets cleared and started for next customer
}
{
{ //Appropriate layout manager
JPanel.fooditems(show.varieties);
food.available(); //selecting food items
Jpanel.sanitizingrooms(clean.water)
things.needed(); //maintaning toiletries
//receive feedbacks
customer.feedback();
show();
Jpanel.[Rating[5-excellent,4-good,3-can be better]
view.rating()
exit(0);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.