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

On completion of this course you are hired by the company Tickets R Us. Part of

ID: 3554937 • Letter: O

Question

On completion of this course you are hired by the company Tickets R Us. Part of your first project is to develop an application to assist with the selling of tickets. After discussing with your client, you identify that each ticket requires two attributes: a serial number and a price. You also identify that three types of tickets are sold: counter tickets, Web tickets, and discount tickets. Following are the specifications: 1. Counter tickets are sold on the day of the event at a ticket counter. They cost £50. 2. Web tickets are purchased on the internet. Web tickets purchased a week in advance of the event are £30 and those purchased less than a week in advance are £40. 3. Discount tickets are a type of Web tickets. They are available for students and senior citizens. They are 50 percent off normal Web ticket prices, i.e. if purchased a week or more in advance they are £15 and if purchased less than a week in advance they are £20. To purchase a discount ticket you either need to be a student or a senior citizen. Proper identification will be needed at the time the ticket is collected. The reason for the discount (student or senior) will be printed on the ticket. For this assignment implement the following: a. A class called Ticket which will be the superclass of both types of tickets (CounterTicket and WebTicket). All common fields and operations (methods) need to be implemented for this class. Following are additional specifications for this class 1. each time a ticket is made, a serial number is incremented. 2. A constructor Ticket() 3. a method public int getPrice() to return the ticket's price 4. a method public String toString() returns a String. This return value can be used to print a ticket b. The class WebTicket inherits from Ticket. o A constructor WebTicket(int days) c. The class DiscountTicket inherits from WebTicket. o A constructor DiscountTicket(int days, String type) o Since discount tickets indicate the type of discount (i.e.

Explanation / Answer

/*OUTPUT
Ticket: [ serial#: 0 Price: 30]
Ticket: [ serial#: 1 Price: 40]
Ticket: [ serial#: 2 Price: 50]
Ticket: [ serial#: 3 Price: 20 Type: Student]
Ticket: [ serial#: 4 Price: 15 Type: Senior]

Total sales: 155
*/

//A class called Ticket which will be the superclass of both types of tickets (CounterTicket and WebTicket).
class Ticket
{
protected static int static_number = 0;
protected int serial_number;
protected int price;
//All common fields and operations (methods) need to be implemented for this class.
//Following are additional specifications for this class
// 1. each time a ticket is made, a serial number is incremented.
// 2. A constructor Ticket()
// 3. a method public int getPrice() to return the ticket's price
// 4. a method public String toString() returns a String. This return value can be used to print a ticket
public Ticket()
{
serial_number = static_number++;
price = 0;
}
public int getPrice()
{
return price;
}
public String toString()
{
return "Ticket: [ serial#: "+serial_number +" Price: "+ price+"]";
}
}
class CounterTicket extends Ticket
{
public static int COUNTER_TICKET_PRICE = 50;
public CounterTicket()
{
super();
price = COUNTER_TICKET_PRICE;
}
}
// b. The class WebTicket inherits from Ticket. o A constructor WebTicket(int days)
class WebTicket extends Ticket
{
public static int WEB_TICKET_PRICE = 30;
public static int WEB_TICKET_LT_WEEK_PRICE = 40;
public WebTicket(int days)
{
super();
if(days > 7)
price = WEB_TICKET_PRICE;
else
price = WEB_TICKET_LT_WEEK_PRICE;
}
}
//c. The class DiscountTicket inherits from WebTicket. o A constructor DiscountTicket(int days, String type)
class DiscountTicket extends WebTicket
{
public static double DISCOUNT = 0.5;
private String type;
public DiscountTicket(int days, String type)
{
super(days);
this.type = type;
if(days > 7)
price = (int)((double)WEB_TICKET_PRICE*DISCOUNT);
else
price =(int)((double)WEB_TICKET_LT_WEEK_PRICE*DISCOUNT);
}
public String toString()
{
return "Ticket: [ serial#: "+ serial_number + " Price: "+ price+ " Type: "+type+ "]";
}
//o Since discount tickets indicate the type of discount (i.e.

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