java Part 2 Programming 20 points Your assignment is to cre

java :-

Part 2: Programming: (20 points)

Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this class). A Customer has a first name (a String), last name (String), ID number (integer), number of matinee tickets (integer), number of normal tickets (integer), total cost (double), number of customers and total tickets (integer). The total tickets and total number of customers variables are used for the class to keep track of total number of tickets sold and total number of customers who ordered tickets, which means they are declared using the static modifier. Each matinee ticket costs $5.00 and each normal ticket costs $7.50. The total cost is computed based on the number of matinee tickets and normal tickets.

Topics:

Every student must work

The class Customer must include the following constructors and methods. (If your class does not contain any of the following methods, points will be deducted.)

Method

Description of the Method

Default constructor sets the first name and last name to \"???”, customer ID, the number of matinee tickets, and the number of normal tickets to 0, and the total cost to 0.0.

Constructs a Customer object given the last name, first name, customer id. The number of matinee ticket and normal tickets are assigned to zero.

Constructs a Customer object given the last name, first name, customer id, number of matinee ticket and number of normal tickets. You have to update total number of tickets too

Returns the first name.

Returns the last name.

Return the customer ID.

Returns the number of matinee tickets

Returns the number of normal tickets.

Returns the total cost.

Sets the first name.

Sets the last name.

Sets the id.

Sets the number of matinee tickets. You need to add the matinee tickets to your total tickets too.

Sets the number of normal tickets. You need to add the normal tickets to your total tickets.

Returns the total number of tickets sold so far (matinee and normal)

Returns the total number of customers so far

Returns true if the ids and names are the same, return false otherwise.

This is a helper (service) method that computes the total cost based on the number of matinee tickets and normal tickets (Each matinee ticket costs $5.00 and each normal ticket costs $7.50). This method will be called by other methods inside of the class Customer anytime the number of matinee tickets or normal tickets is updated.

Compares the total number of tickets for 2 customers and returns the Customer who has more tickets. If the total tickets are same, the first customer is returned.

Returns a String with information on each Customer using the following format:

First name: Grace
Last name: Hopper
Customer ID: 888777888 Number of Matinee Ticket(s): 10 Number of Normal Ticket(s): 50 Total cost: $375.00

Make use of the NumberFormat class to format the total cost.

Save the Customer class in a file called Customer.java. Use Assignment6.java class posted on Blackboard under homework 6, which has the main method to create new Customer objects and to test your class.

Important Notes: Your class should have exactly the method headers that are described or otherwise your class will not work with the test driver program (Assignment6.java) that is provided. You should never change the test driver program if the test driver is provided but instead make changes to your class to make it work.

A sample output is shown below.

Helpful hints for doing this assignment:

work on it in steps – write one method, test it with a test driver and make sure it works before going on to the next method

always make sure your code compiles before you add another method

your methods should be able to be called in any order

Sample Output:

******** Customer\'s info: ********** First Name: ???
Last Name: ???
Customer ID: 0

Number of Matinee Ticket(s): 0 Number of Normal Ticket(s): 0 Total Cost: $0.00

******** Customer\'s info: ********** First Name: Grace
Last Name: Hopper
Customer ID: 12345

Number of Matinee Ticket(s): 0 Number of Normal Ticket(s): 30 Total Cost: $225.00

******** Customer\'s info: ********** First Name: Smith
Last Name: Megan
Customer ID: 555666777

Number of Matinee Ticket(s): 0 Number of Normal Ticket(s): 0 Total Cost: $0.00

Enter customer\'s info:
First Name: Ginni
Last Name: Rometty
ID #: 345543
Number of Matinee Tickets: 12 Number of Normal Tickets: 13

******** Customer\'s info using get methods:********

First name: Ginni Last name: Rometty Customer ID: 345543 Matinee ticket(s): 12 Normal ticket(s): 13 Total cost: 157.5

******** Customer\'s info: ********** First Name: Ginni
Last Name: Rometty
Customer ID: 345543

Number of Matinee Ticket(s): 12

Number of Normal Ticket(s): 13 Total Cost: $157.50

*******Customer who has more tickets:***** First Name: Grace
Last Name: Hopper
Customer ID: 12345

Number of Matinee Ticket(s): 0 Number of Normal Ticket(s): 30 Total Cost: $225.00

********First comparison****** customer2 and customer3 are different.

********Second comparison******
customer2 and customer3 are the same customer.

**************
Total number of customers: 3 Total number of tickets: 80 Press any key to continue .

The Assignment6.java file :-

Method

Description of the Method

  public Customer( )  

Default constructor sets the first name and last name to \"???”, customer ID, the number of matinee tickets, and the number of normal tickets to 0, and the total cost to 0.0.

  public Customer (String lname,  String fname, int id)  

Constructs a Customer object given the last name, first name, customer id. The number of matinee ticket and normal tickets are assigned to zero.

  public Customer (String lname,  String fname, int id, int  initMatinee, int initNormal )  

Constructs a Customer object given the last name, first name, customer id, number of matinee ticket and number of normal tickets. You have to update total number of tickets too

  public String getFirstName( )  

Returns the first name.

  public String getLastName()  

Returns the last name.

  public int getCustomerID()  

Return the customer ID.

  public int getMatineeTickets( )  

Returns the number of matinee tickets

  public int getNormalTickets( )  

Returns the number of normal tickets.

  public double getTotalCost()  

Returns the total cost.

  public void setFirstName (String  fname)  

Sets the first name.

  public void setLastName (String  fname)  

Sets the last name.

  public void setCustomerID(int id)  

Sets the id.

  public void setMatineeTickets(int  matineeNum)  

Sets the number of matinee tickets. You need to add the matinee tickets to your total tickets too.

  public void setNormalTickets(int  normalNum)  

Sets the number of normal tickets. You need to add the normal tickets to your total tickets.

  public static int getTickets()  

Returns the total number of tickets sold so far (matinee and normal)

  public static int getNumCustomers()  

Returns the total number of customers so far

  public boolean equals (Customer  other)  

Returns true if the ids and names are the same, return false otherwise.

  private void computeTotalCost( )  

This is a helper (service) method that computes the total cost based on the number of matinee tickets and normal tickets (Each matinee ticket costs $5.00 and each normal ticket costs $7.50). This method will be called by other methods inside of the class Customer anytime the number of matinee tickets or normal tickets is updated.

  public Customer hasMore (Customer  other)  

Compares the total number of tickets for 2 customers and returns the Customer who has more tickets. If the total tickets are same, the first customer is returned.

  public String toString( )  

Returns a String with information on each Customer using the following format:

First name: Grace
Last name: Hopper
Customer ID: 888777888 Number of Matinee Ticket(s): 10 Number of Normal Ticket(s): 50 Total cost: $375.00

Make use of the NumberFormat class to format the total cost.

Solution

JAVA CODE: Customer.java

import java.util.ArrayList;
public class Customer {
private String FirstName;
private String LastName;
private int Cid;
private int totalMatinee;
private int totalNormal;
private double TotalCost;

private ArrayList<Integer> customer=new ArrayList<Integer>();
private ArrayList<Integer> normal=new ArrayList<Integer>();
private ArrayList<Integer> matinee=new ArrayList<Integer>();

public Customer(){
   System.out.println(\"First Name: \" + FirstName + \"\ \" + \"Last Name: \" + LastName + \"\ \" + \"Customer ID: \" + Cid + \"\ \" + \"Number of Matinee Ticket(s): \" + totalMatinee + \"Number of Normal Ticket(s):\" + totalNormal + \"Total Cost: $\" + TotalCost );
   }

public Customer (String lname,String fname, int id ){
   FirstName=fname;
   LastName=lname;
   Cid=id;
}
public Customer (String lname,String fname, int id, int initMatinee, int initNormal){
   FirstName=fname;
   LastName=lname;
   Cid=id;
   totalMatinee=initMatinee;
   totalNormal=initNormal;
  
  
}

public String getFirstName(){
   return FirstName;
}
public String getLastName(){
   return LastName;
}
public int getCustomerID(){
   return Cid;
}
public int getMatineeTickets(){
   return totalMatinee;
}
public int getNormalTickets(){
   return totalNormal;
}
public double getTotalCost(){
   return TotalCost;
}
public void setFirstName (String fname){
   this.FirstName=fname;
}

public void setLastName (String lname){
   this.LastName=lname;
}
public void setCustomerID(int id){
   this.Cid=id;
   customer.add(id);
}

public void setMatineeTickets(int matineeNum){
   this.totalMatinee=matineeNum;
   matinee.add(matineeNum);
  
}
public void setNormalTickets(int normalNum){
   this.totalNormal=normalNum;
   normal.add(normalNum);
   }


public static int getNumCustomers(ArrayList<Integer> customer){
   return customer.size();
}
public static int getTickets(ArrayList<Integer> matinee,ArrayList<Integer> normal){
   return matinee.size()+normal.size();
}
private void computeTotalCost(ArrayList<Integer> matinee,ArrayList<Integer> normal){
   double c1=matinee.size()*5.00;
   double c2=normal.size()*7.5;
   System.out.println((c1+c2)+\"\ \");
  
}
public boolean equals (int Cid,int Cid1){
   if(Cid==Cid1){
       return true;
   }
   else
       return false;
}
public Customer hasMore (Customer c,Customer d){
   if((c.getMatineeTickets()+c.getNormalTickets())>(d.getMatineeTickets()+d.getNormalTickets())){
       return c;
   }
   else{
       return d;
   }
}

public String toString(){

return this.FirstName + \"\ \" +this. LastName + \"\ \" + this. Cid + \"\ \" +this. totalMatinee + this.totalNormal + this.TotalCost
  
   }
}

java :- Part 2: Programming: (20 points) Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this c
java :- Part 2: Programming: (20 points) Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this c
java :- Part 2: Programming: (20 points) Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this c
java :- Part 2: Programming: (20 points) Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this c
java :- Part 2: Programming: (20 points) Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this c
java :- Part 2: Programming: (20 points) Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this c
java :- Part 2: Programming: (20 points) Your assignment is to create a file called Customer.java containing a class Customer (there is no main method in this c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site