In: Computer Science
Create a java program with class Customer: Name, Surname, ID (incremental ID by 1 for each new customer), Email, Phone, Address. The program must create New customer, and Print information for customer with a certain ID.
public class Customer {
private String name;
private String surname;
public static int id=0; //starting number for issuing
IDs
private String email;
private String phone;
private String address;
/**
* @param name
* @param surname
* @param email
* @param phone
* @param address
*/
public Customer(String name, String surname, String
email, String phone,
String address)
{
super();
this.name = name;
this.surname = surname;
this.email = email;
this.phone = phone;
this.address = address;
id++; //increment ID everytime a
customer is created
}
public void printCustomer(){
System.out.println("CUSTOMER
INFORMATION");
System.out.println("ID:
"+id);
System.out.println("Names:
"+this.name+ " " +this.surname);
System.out.println("Email:
"+this.email);
System.out.println("Phone:
"+this.phone);
System.out.println("Address:
"+this.address);
}
public static void main(String[] args) {
Customer customer1 = new
Customer("James","Wills","[email protected]","+xx
04564xxx","Washington Street");
customer1.printCustomer();
System.out.println("");
Customer customer2 = new
Customer("Mary","Tall","[email protected]","+xx 456264xxx","New
York");
customer2.printCustomer();
}
}
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER
PLEASE PLEASE GIVE A THUMBS UP