Question
Write, test and document (internally) a Java program, and required class definitions, to solve the following problem: A) Class Ticket has the following attributes and
Write, test and document (internally) a Java program, and required class definitions, to solve the following problem:
A) Class Ticket has the following attributes and operations
attributes
name of purchaser
address of purchaser
date of purchase
operations
constructor with parameters for each attribute
accessor and mutator methods for each attribute
a toString method
B) In addition to Ticket attributes and operations, class SeasonTicket has the following attributes and operations:
attributes
total number of games in the season
total price for the season
operations
a constructor with parameters for the Ticket and SeasonTicket attributes
accessor and mutator methods for the total number of games and the total price
a toString method
C) In addition to Ticket attributes and operations, class PerGameTicket has the following attributes and operations:
attributes
date of game
ticket price
operations
a constructor with parameters for the Ticket and PerGameTicket attributes
accessor and mutator methods for the date and price attributes
a toString method
D) In addition to Ticket attributes and operations, class Package has the following attributes and operations:
attributes
number of games in the package
the date of each game
package price
operations
a constructor with parameters for the Ticket and Package attributes
accessor and mutator methods for the number of games, the date of each game and the package price
a toString method
E) Write a Java program (with a main method) which creates and initializes a 1-dimensional array of Ticket objects. (This should include objects of all four class types.) Output the attributes for each object. In addition, determine and output the following:
the total price of all tickets
the name of each season ticket holder
the total number of season tickets
the total number of per game tickets
the total number of packages
Create and use a text file to store your input data. Read the contents of the text file as input to your program. Include appropriate error checking in your program.
F) Write an interface definition called Amount which has one method:
public double getPrice();
and which is implemented by each of class SeasonTicket, PerGameTicket and Package. Method getPrice() should return the average price per game.
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