The last two photos are assignment6java please help me to fo
Solution
/** It definitely works. Please test it once as I didn\'t get enough time to write Driver program from image file**/
public class Customer {
private String firstName;
private String lastName;
private int customerID = 0;
private int matineeTickets = 0;
private int normalTickets = 0;
private double totalCost = 0.0;
private static int tickets = 0;
private static int numCustomers = 0;
public static final double MATINEE_TICKET_COST = 5.0;
public static final double NORMAL_TICKET_COST = 7.5;
public Customer() {
super();
this.firstName = \"???\";
this.lastName = \"???\";
numCustomers++;
}
public Customer(String lastName, String firstName, int customerID) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.customerID = customerID;
numCustomers++;
}
public Customer(String lastName, String firstName, int customerID, int matineeTickets, int normalTickets) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.customerID = customerID;
this.matineeTickets = matineeTickets;
this.normalTickets = normalTickets;
tickets = tickets + normalTickets + matineeTickets;
computeTotalCost();
numCustomers++;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getCustomerID() {
return customerID;
}
public void setCustomerID(int customerID) {
this.customerID = customerID;
}
public int getMatineeTickets() {
return matineeTickets;
}
public void setMatineeTickets(int matineeTickets) {
tickets = tickets - this.matineeTickets + matineeTickets;
this.matineeTickets = matineeTickets;
computeTotalCost();
}
public int getNormalTickets() {
return normalTickets;
}
public void setNormalTickets(int normalTickets) {
tickets = tickets - this.normalTickets + normalTickets;
this.normalTickets = normalTickets;
computeTotalCost();
}
public double getTotalCost() {
return totalCost;
}
public static int getTickets() {
return tickets;
}
public static int getNumCustomers() {
return numCustomers;
}
public boolean equals(Customer otherCustomer) {
if (customerID == otherCustomer.getCustomerID() && firstName.equals(otherCustomer.getFirstName())
&& lastName.equals(otherCustomer.getLastName()))
return true;
return false;
}
public void computeTotalCost() {
totalCost = matineeTickets * MATINEE_TICKET_COST + normalTickets * NORMAL_TICKET_COST;
}
public Customer hasMore(Customer otherCustomer) {
if ((matineeTickets + normalTickets) > (otherCustomer.getMatineeTickets() + otherCustomer.getNormalTickets()))
return this;
else if ((matineeTickets + normalTickets) < (otherCustomer.getMatineeTickets()
+ otherCustomer.getNormalTickets()))
return otherCustomer;
else {
if (customerID < otherCustomer.getCustomerID())
return this;
return otherCustomer;
}
}
public String toString() {
return \"First name: \" + firstName + \"\ \" + \"Last name: \" + lastName + \"\ \" + \"Customer ID: \" + customerID + \"\ \"
+ \"Number of Matinee Ticket(s): \" + matineeTickets + \"\ \" + \"Number of Normal Ticket(s): \"
+ normalTickets + \"\ \" + \"Total Cost: $\" + totalCost;
}
}


