In: Computer Science
Java.
Part 1 of 4 - Amusement Park Programming Project
Requirements:
Class:
Ticket – models admission tickets.
Instance Fields:
Constructors and Methods:
import java.text.SimpleDateFormat;
import java.util.Date;
public class Ticket {
private long number;
private String category;
private String holder;
private Date date;
private double price;
private boolean status;
public Ticket(){
}
public Ticket(String category,String holder,Date
date,double price,boolean status){
this.category=category;
this.holder=holder;
this.date=date;
this.price=price;
this.status=status;
}
public void setPrice(double price){
this.price=price;
}
public void changePurchaseStatus(boolean
status){
this.status=status;
}
public long getNumber() {
return number;
}
public String getCategory() {
return category;
}
public String getHolder() {
return holder;
}
public Date getDate() {
return date;
}
public double getPrice() {
return price;
}
public String toString(){
SimpleDateFormat formatter = new
SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return "Number:
"+this.number+"\nCategory: "+this.category+"\nHolder:
"+this.holder+""
+ "\nDate:
"+formatter.format(this.date)+"\nPrice: "+this.price+"\nStatus:
"+this.status;
}
}