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

Question 1 Write, test and document (internally) a Java program, and required cl

ID: 3728067 • Letter: Q

Question

Question 1 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: o attributes - name of purchaser - address of purchaser - date of purchase o 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: o attributes -total number of games in the season total price for the season o 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: o attributes - date of game - ticket price o 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: o attributes - number of games in the package - the date of each game - package price o 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

Explanation / Answer

Hi ,

As per the problem statement , Please find the solution below:

Note: As per the chegg rules , I implemented the first 4 sub parts,

Please find below :

Ticket.java

import java.util.Date;

public class Ticket {

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public Ticket(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase) {

super();

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public String getNameOfPurchaser() {

return nameOfPurchaser;

}

public void setNameOfPurchaser(String nameOfPurchaser) {

this.nameOfPurchaser = nameOfPurchaser;

}

public String getAddressOfPurchaser() {

return addressOfPurchaser;

}

public void setAddressOfPurchaser(String addressOfPurchaser) {

this.addressOfPurchaser = addressOfPurchaser;

}

public Date getDateOfPurchase() {

return dateOfPurchase;

}

public void setDateOfPurchase(Date dateOfPurchase) {

this.dateOfPurchase = dateOfPurchase;

}

@Override

public String toString() {

return "Ticket [nameOfPurchaser=" + nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser

+ ", dateOfPurchase=" + dateOfPurchase + "]";

}

}

SeasonTicket.java:

import java.util.Date;

public class SeasonTicket {

private int totalNoOfGames;

private float price;

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public SeasonTicket(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase, int totalNoOfGames, float price, Ticket ticket) {

super();

this.totalNoOfGames = totalNoOfGames;

this.price = price;

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public int getTotalNoOfGames() {

return totalNoOfGames;

}

public void setTotalNoOfGames(int totalNoOfGames) {

this.totalNoOfGames = totalNoOfGames;

}

public float getPrice() {

return price;

}

public void setPrice(float price) {

this.price = price;

}

@Override

public String toString() {

return "SeasonTicket [totalNoOfGames=" + totalNoOfGames + ", price=" + price + ", nameOfPurchaser="

+ nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser + ", dateOfPurchase=" + dateOfPurchase

+ "]";

}

}

PerGameTicket.java:

import java.util.Date;

public class PerGameTicket {

private Date dateOfGame;

private float tickerPrice;

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public PerGameTicket(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase, Date dateOfGame, float tickerPrice, Ticket ticket) {

super();

this.dateOfGame = dateOfGame;

this.tickerPrice = tickerPrice;

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public Date getDateOfGame() {

return dateOfGame;

}

public void setDateOfGame(Date dateOfGame) {

this.dateOfGame = dateOfGame;

}

public float getTickerPrice() {

return tickerPrice;

}

public void setTickerPrice(float tickerPrice) {

this.tickerPrice = tickerPrice;

}

@Override

public String toString() {

return "PerGameTicket [dateOfGame=" + dateOfGame + ", tickerPrice=" + tickerPrice + ", nameOfPurchaser="

+ nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser + ", dateOfPurchase=" + dateOfPurchase

+ "]";

}

}

Package.java:

import java.util.Date;

public class Package {

private int numberOfGames;

private Date dateOfEachGame;

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public Package(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase, int numberOfGames,

Date dateOfEachGame) {

super();

this.numberOfGames = numberOfGames;

this.dateOfEachGame = dateOfEachGame;

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public Date getDateOfEachGame() {

return dateOfEachGame;

}

public void setDateOfEachGame(Date dateOfEachGame) {

this.dateOfEachGame = dateOfEachGame;

}

public int getNumberOfGames() {

return numberOfGames;

}

public void setNumberOfGames(int numberOfGames) {

this.numberOfGames = numberOfGames;

}

@Override

public String toString() {

return "Package [numberOfGames=" + numberOfGames + ", dateOfEachGame=" + dateOfEachGame + ", nameOfPurchaser="

+ nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser + ", dateOfPurchase=" + dateOfPurchase

+ "]";

}

}

Thanks

Hi ,

As per the problem statement , Please find the solution below:

Note: As per the chegg rules , I implemented the first 4 sub parts,

Please find below :

Ticket.java

import java.util.Date;

public class Ticket {

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public Ticket(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase) {

super();

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public String getNameOfPurchaser() {

return nameOfPurchaser;

}

public void setNameOfPurchaser(String nameOfPurchaser) {

this.nameOfPurchaser = nameOfPurchaser;

}

public String getAddressOfPurchaser() {

return addressOfPurchaser;

}

public void setAddressOfPurchaser(String addressOfPurchaser) {

this.addressOfPurchaser = addressOfPurchaser;

}

public Date getDateOfPurchase() {

return dateOfPurchase;

}

public void setDateOfPurchase(Date dateOfPurchase) {

this.dateOfPurchase = dateOfPurchase;

}

@Override

public String toString() {

return "Ticket [nameOfPurchaser=" + nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser

+ ", dateOfPurchase=" + dateOfPurchase + "]";

}

}

SeasonTicket.java:

import java.util.Date;

public class SeasonTicket {

private int totalNoOfGames;

private float price;

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public SeasonTicket(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase, int totalNoOfGames, float price, Ticket ticket) {

super();

this.totalNoOfGames = totalNoOfGames;

this.price = price;

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public int getTotalNoOfGames() {

return totalNoOfGames;

}

public void setTotalNoOfGames(int totalNoOfGames) {

this.totalNoOfGames = totalNoOfGames;

}

public float getPrice() {

return price;

}

public void setPrice(float price) {

this.price = price;

}

@Override

public String toString() {

return "SeasonTicket [totalNoOfGames=" + totalNoOfGames + ", price=" + price + ", nameOfPurchaser="

+ nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser + ", dateOfPurchase=" + dateOfPurchase

+ "]";

}

}

PerGameTicket.java:

import java.util.Date;

public class PerGameTicket {

private Date dateOfGame;

private float tickerPrice;

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public PerGameTicket(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase, Date dateOfGame, float tickerPrice, Ticket ticket) {

super();

this.dateOfGame = dateOfGame;

this.tickerPrice = tickerPrice;

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public Date getDateOfGame() {

return dateOfGame;

}

public void setDateOfGame(Date dateOfGame) {

this.dateOfGame = dateOfGame;

}

public float getTickerPrice() {

return tickerPrice;

}

public void setTickerPrice(float tickerPrice) {

this.tickerPrice = tickerPrice;

}

@Override

public String toString() {

return "PerGameTicket [dateOfGame=" + dateOfGame + ", tickerPrice=" + tickerPrice + ", nameOfPurchaser="

+ nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser + ", dateOfPurchase=" + dateOfPurchase

+ "]";

}

}

Package.java:

import java.util.Date;

public class Package {

private int numberOfGames;

private Date dateOfEachGame;

private String nameOfPurchaser;

private String addressOfPurchaser;

private Date dateOfPurchase;

public Package(String nameOfPurchaser, String addressOfPurchaser, Date dateOfPurchase, int numberOfGames,

Date dateOfEachGame) {

super();

this.numberOfGames = numberOfGames;

this.dateOfEachGame = dateOfEachGame;

this.nameOfPurchaser = nameOfPurchaser;

this.addressOfPurchaser = addressOfPurchaser;

this.dateOfPurchase = dateOfPurchase;

}

public Date getDateOfEachGame() {

return dateOfEachGame;

}

public void setDateOfEachGame(Date dateOfEachGame) {

this.dateOfEachGame = dateOfEachGame;

}

public int getNumberOfGames() {

return numberOfGames;

}

public void setNumberOfGames(int numberOfGames) {

this.numberOfGames = numberOfGames;

}

@Override

public String toString() {

return "Package [numberOfGames=" + numberOfGames + ", dateOfEachGame=" + dateOfEachGame + ", nameOfPurchaser="

+ nameOfPurchaser + ", addressOfPurchaser=" + addressOfPurchaser + ", dateOfPurchase=" + dateOfPurchase

+ "]";

}

}

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