Post date: Nov 22, 2015 5:21:0 AM
Please complete, for all courses, the FIRST 3 TYPES of surveys in the ENGLISH version: http://10.30.16.15/esurvey_male/login.php
Defining Classes 1
4.3 Overloading
Recommended Self-Test Exercises:
p 257-258: Ex. 20-23.
In-Class Exercises:
Ex. 1:
Create a class called Customer
Within the Customer class, add an overloaded method called setCustInfo
Depending on how the setCustInfo 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 Customer).
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 object references to different Customer objects.
Use each variation of the setCustInfo method to provide information for each Customer object. Display the contents of each Customer object
Ex. 2:
Create a class called Utils
Write a method called average that accepts two integer parameters and returns their average as a floating point value;
Overload the average method such that if three integers are provided as parameters, the method returns the average of all three;
Overload the average method to accept four integer parameters and return their average
Write a method called multiConcat that takes a String and an integer as parameters. Return a String that consists of the string parameter concatenated with itself count times, where count is the integer parameter. For example, if the parameter values are "hi" and 4, the return value is "hihihihi". Return the original string if the integer parameter is less than 2.
Overload the multiConcat method such that if the integer parameter is not provided, the method returns the string concatenated with itself. For example, if the parameter is "test", the return value is "testtest"