Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

JAVA

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago