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

Use BlueJ to create a project for an application that keeps track of ticket sale

ID: 3814350 • Letter: U

Question

Use BlueJ to create a project for an application that keeps track of ticket sales for a theater. The project includes an abstract class as well as several subclasses that need to be implemented. The TicketTester class has a main method that can be run to test the program.

All tickets have a serial number and a price. The class Ticket is specified as an abstract class. Each ticket has a unique serial number that is assigned when the ticket is constructed. For all ticket classes, the toString method returns a String containing information for that ticket. Three additional classes are used to represent the different types of tickets and are described below. Using the class hierarchy and the specifications given below, write complete class declarations for the Walkup, Advance, and StudentAdvance classes. The code for the ticket class will be at the bottom of this question. Thank you!

Ticket

Complete the getNextSerialNumber() method

Updates the serialCounter and then returns a new unique serial number based on the counter

Walkup

Include all necessary instance variables and implementations of its constructor and method(s)

These tickets are purchased on the day of the event and cost $50

The constructor does not need any parameters

Advance  

Include all necessary instance variables and implementations of its constructor and method(s)

The constructor should include a parameter that indicates the number of days in advance that this ticket is being purchased.

Tickets purchased 10 or more days in advance cost $30; purchased 9 or fewer days in advance cost $40

StudentAdvance

Include all necessary instance variables and implementations of its constructor and method(s)

The constructor should take a parameter that indicates the number of days in advance that this ticket is being purchased

The toString method should include a notation that a student ID is requred for this ticket

A StudentAdvance ticket costs half of what that Advance ticket would normally cost. If the pricing scheme for Advance tickets changes (e.g. prices increase by $5), the StudentAdvance price should continue to be computed correctly with no code modifications to the StudentAdvance class.

Ticket class code:

/**
* Ticket.java 05/06/05
*
* @author - Robert Glen Martin
* @author - School for the Talented and Gifted
* @author - Dallas ISD
*
* My solution to 2005 A2
*/

public abstract class Ticket
{
   private static int serialCounter = 100;

   private int serialNumber; // unique ticket id number

   public Ticket()
   {
       serialNumber = getNextSerialNumber();
   }

   // returns the price for this ticket
   public abstract double getPrice();

   // returns a string with information about the ticket
   public String toString()
   {
       return "Number: " + serialNumber + " Price: " + getPrice();
   }

   // returns a new unique serial number
   private static int getNextSerialNumber()
   {
   //complete this method
       return -1; //replace this
   }
}

Explanation / Answer

Based on the above problem statement please find the below classes implemented in java

****************************

#This is the ticket class where i have completed the method getNextSerialNumber(){}{}

Ticket.java

package WordNode;

public abstract class Ticket
{
   private static int serialCounter = 100;
   private static int serialNumber; // unique ticket id number
   public Ticket()
   {
       serialNumber = getNextSerialNumber();
   }
   // returns the price for this ticket
   public abstract double getPrice();
   // returns a string with information about the ticket
   public String toString()
   {
       return "Number: " + serialNumber + " Price: " + getPrice();
   }
   // returns a new unique serial number
   private static int getNextSerialNumber()
   {
       //complete this method
       serialNumber = ++serialCounter;
       return serialNumber; //replace this
   }
}

****************************

Walkup.java

#This class extends ticket.java and override the unimplemeted methods

package WordNode;

public class Walkup extends Ticket{


   public Walkup() {
       super();
   }

   double cost = 50;

   @Override
   public double getPrice() {
       // TODO Auto-generated method stub
       if(cost == 50){
           System.out.println("The tickets are purchased on the same day of the event");
       }else{

           System.out.println("The tickets are not purchased on the same day");
       }


       return 0;
   }

}

*************

Advance.java

#This class extends ticket.java and override the unimplemeted methods

package WordNode;

public class Advance extends Ticket{

   int numberofdays=0;


   int ticketsPurchased;

   public Advance(int numberofdays) {
       super();
       this.numberofdays = numberofdays;
   }

   @Override
   public double getPrice() {
       // TODO Auto-generated method stub
       if(ticketsPurchased >= 10){
           System.out.println("The tickets being purchased cost is 30$");
       }
       else if(ticketsPurchased <= 9){
           System.out.println("The tickets being purchased cost is 40$");

       }
       else
           System.out.println("The Ticket not being purchased");

       return numberofdays;
   }

}

******************************************

#This class extends to ticket.java and override the unimplemented methods

StudentAdvance.java

package WordNode;

public class StudentAdvance extends Ticket {


   double numberofdays=0.0;

   int student_ID;

   double advanceTickets;

   double studentAdvanceTicket;

   @Override
   public String toString() {
       return "StudentAdvance [numberofdays=" + numberofdays + ", student_ID="
               + student_ID + "]";
   }

   public StudentAdvance(double numberofdays) {
       super();
       this.numberofdays = numberofdays;
   }

   @Override
   public double getPrice() {
       // TODO Auto-generated method stub
       if(advanceTickets >= 5){
           studentAdvanceTicket = advanceTickets/2;
           System.out.println(studentAdvanceTicket);
       }
       else{
           System.out.println("StudentAdvance is not Increased");
       }

       return studentAdvanceTicket++;
   }

}

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