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
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 ageStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started