Attached Files Write two java classes for this assignment pe
Attached Files:
Write two java classes for this assignment per the two uml diagrams below. The TicketTest program has been added to this assignment for instantiating and testing out both the Ticket and Seat classes. Download the TicketTest and place it in the same directory as your Ticket and Seat classes. First compile all three classes, if there are compile errors though your Ticket and Seat classes compile that means your Ticket and Seat classes do not meet the requirements specified in the following uml diagrams. If all three classes do compile, run TicketTest. The output you should see is provided below.
Do notice that the Ticket class contains a field(variable) for a Seat object, this is called an aggregation of objects. Also take note that the toString() and equals() methods are required for both classes.
First Ticket:
TicketEvent: Hedwig and The Angry Inch
Ticket Price: 58.25
Event Date: Mon Apr 10 14:00:00 EDT 2017
Seat
Location: Orchestra Center Right
Aisle: HH
Seat Number: 10
Second Ticket:
TicketEvent: Wicked
Ticket Price: 72.0
Event Date: Fri Jun 16 14:00:00 EDT 2017
Seat
Location: Balcony Left
Aisle: DD
Seat Number: 7
Are the tickets equal:false
Are the tickets equal now:true
First Ticket:
Ticket
Event: Wicked
Ticket Price: 72.0
Event Date: Fri Jun 16 14:00:00 EDT 2017
Seat
Location: Balcony Left
Aisle: DD
Seat Number: 7
Second Ticket:
Ticket
Event: Wicked
Ticket Price: 72.0
Event Date: Fri Jun 16 14:00:00 EDT 2017
Seat
Location: Balcony Left
Aisle: DD
Seat Number: 7
TicketTest.java attachment
Solution
Ticket.java
import java.util.*;
import java.text.*;
public class Ticket{
String event;
Double price;
Calendar dateOfEvent;
Seat seat;
public void setEvent(String event){
this.event = event;
}
public void setTicketPrice(Double price){
this.price = price;
}
public void setDateOfEvent(Calendar dateOfEvent){
this.dateOfEvent = dateOfEvent;
}
public void setSeat(Seat seat){
this.seat = seat;
}
public String getEvent(){
return this.event;
}
public Double getPrice(){
return this.price;
}
public Calendar getDateOfEvent(){
return this.dateOfEvent;
}
public Seat getSeat(){
return this.seat;
}
public String toString(){
SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy MMM dd HH:mm:ss\");
String date = sdf.format(dateOfEvent);
return \"Ticket\ Event: \" + this.event + \"\ Ticket Price: \" + this.price + \"\ dateOfEvent: \" + date + \"\ \" + this.seat.toString();
}
public boolean equals(Ticket ticket2){
if(this.event == ticket2.getEvent() && this.price == ticket2.getPrice() && this.dateOfEvent == ticket2.getDateOfEvent() && this.seat.equals(ticket2.getSeat())){
return true;
}
else{
return false;
}
}
}
Seat.java
public class Seat{
String location;
String aisle;
int seatNumber;
public String getLocation(){
return this.location;
}
public String getAisle(){
return this.aisle;
}
public int getSeatNumber(){
return this.seatNumber;
}
public void setLocation(String location){
this.location = location;
}
public void setAisle(String aisle){
this.aisle = aisle;
}
public void setSeatNumber(int seatNumber){
this.seatNumber = seatNumber;
}
public String toString(){
return \"Seat\ Location: \" + this.location +\"\ Aisle: \" + this.aisle + \"\ Seat Number: \" + this.seatNumber + \"\ \";
}
public boolean equals(Seat seat2){
if(this.location == seat2.getLocation() && this.aisle == seat2.getAisle() && this.seatNumber == seat2.getSeatNumber()){
return true;
}
else{
return false;
}
}
}


