Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following program represents tickets for sporting events sold by the university stadium. Tickets are less expensive when ordered in advance and students get a
The following program represents tickets for sporting events sold by the university stadium. Tickets are less expensive when ordered in advance and students get a discount on advance tickets. Several classes work together via inheritance to provide this functionality used by the ticket booth operators. Read all of the classes before typing in the missing code.
Ticket Superclass
public
class Ticket
protected int serialNum;
private static num ;
public Ticket
getNextSerialNum;
public abstract double getPrice;
public
toString
"Number: serialNum
Price: getPrice;
private static int getNextSerialNum
num;
serialNum
;
return serialNum;
Walkup Subclass
public class
extends Ticket
private double price ;
public Walkup
super;
public
getPrice
return price;
Advance Subclass
public class Advance extends Ticket
private double price;
private int days;
public Advanceint d
;
days
;
public double getPrice
if days
price ;
price ;
return price;
StudentAdvance Subclass
public class StudentAdvance
public StudentAdvanceint d
superd;
public double getPrice
return
getPrice;
public String toString
return super.toString
student ID required;
Driver Class TicketBooth
import java.util.Scanner;
public class TicketBooth
public static void mainString args
Scanner scan
;
ArrayList tix new ArrayList;
int choice, days;
temp;
System.out.printlnWelcome ticket booth operator!
Just type the ticket type number to generate a ticket.";
System.out.printlnMenu:
Walkup Ticket
Advance Ticket
Student Advance Ticket
Quit;
choice
;
scan.nextLine;
while
if choice
System.out.printlnNumber of days until the show?";
scan.nextInt;
scan.nextLine;
if choice
temp new
days;
else
temp new StudentAdvancedays;
else
temp new Walkup;
tix.add
;
System.out.printlntemp;
System.out.printlnWelcome ticket booth operator!
Just type the ticket type number to generate a ticket.";
System.out.printlnMenu:
Walkup Ticket
Advance Ticket
Student Advance Ticket
Quit;
choice scan.nextInt;
scan.nextLine;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started