Function overloading or method overloading allows oneto create multiple functions of the same name with different implementations.
Question:
Function overloading or method overloading allows one to create multiple functions of the same name with different implementations.
make a class named Chat.
Add the following variables:
1. List
2. List
3. HashMap
Add the following methods:
1. void Chat() - Initializes members , files, message.
2. Method add which has 3 variations, each with a return type void:.
- Variation 1 has a parameter String[] names . This copies the values from names to the list members.
- Variation 2 has a parameter int[] ids . This copies the values from ids to the list files.
- Variation 3 has 2 parameters: int id and String newMessage. This adds the key value pair <id, newMessage> to the map message.
3. Method remove which has 3 variations, each with a return type void:.
- Variation 1 has a parameter String[] names. This removes all the values in names from the list members. If some name does not exist, print "Member with name {name} does not exist".
- Variation 2 has a parameter int[] ids. This removes all the values in ids from the list files. If some id does not exist, print "File with id {id} does not exist".
- Variation 3 has a parameter int id. This removes the message with the key id from the map message. If some id does not exist, print "Message with id {id} does not exist".
4. void printConversation() - Prints the following -
"Total number of members in the conversation are {totalMembers}"
"The names of these members are {all the names}" where the names are separated by a single space.
"Total number of files in the conversation are {totalFiles}"
"The messages in the conversation are {all the messages}" where each message is surrounded by single quotes and messages are separated by a single space.
Concepts of Database Management
ISBN: 978-1285427102
8th edition
Authors: Philip J. Pratt, Mary Z. Last