Question: JAVA Here is the Customer class public class Customer { private static int custNum = 0; private int id; private String name; private int age;

JAVA

JAVA Here is the Customer class public class Customer { private static

Here is the Customer class

public class Customer { private static int custNum = 0; private int id; private String name; private int age; private String phoneNumber;

public Customer() { this.name = ""; this.age = 0; this.phoneNumber = "0000000000"; }

public static int getUniqueEmpId() { custNum = custNum + 1; return custNum; }

public void setName(String name) { this.name = name; }

public void setAge(int age) { this.age = age; }

public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; }

public void setId(int id) { this.id = id; }

public String getName() { return name; }

public int getAge() { return age; }

public String getPhoneNumber() { return phoneNumber; }

public int getId() { return id; }

@Override public String toString() { return this.id + " " + this.name + ", " + this.phoneNumber + ", " + this.age; } }

(i) Write a class called Customer that has data fields for ID, age, name and phoneNumber o For the age, name and phoneNumber fields add getter and setter o Specify one constructor to initialise the age, name and phoneNumber o The ID field should automatically be filled in with the next available ID o Overwrite the toString method so that it returns a string description methods field. (starting at 1) for the customer in the format below. 1235 John Smyth, 0861234567, 40 (i) Use the Customer class to implement the Comparable interface and provide implementation of the compareTo method, which will compare two Customer objects by their age

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!