Exercise 2: Using
Overloaded Methods
The objective of this
exercise is to write a method that is overloaded several times.
Task -
Developing a Class With an Overloaded Method
In this task,
you write a test class with an overloaded method. Follow these steps to
write your class:
- Go to the methods directory.
- Create a
class called Customer.java.
- Within
the Customer.java class, add
an overloaded method called setCustomerInfo.
Depending
on how the setCustomerInfo method is called, it
does one of the following:
- Sets
the
ID, name, address, and phone number for a Customer object (this is the
minimum information needed for a new Cutomer).
- Sets
the
ID, name, address, phone number, and email address for a Customer object.
- Create
a new test class called CustomerTest.
- In the main method:
- Create
two objects references to different Customer objects.
- Use
each
variation of the setCustomerInfo method to provide
information for each Customer object.
- Display
the contents of each Customer object.