Question: Function overloading or method overloading allows oneto create multiple functions of the same name with different implementations. make a class named Chat . Add
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.
Step by Step Solution
There are 3 Steps involved in it
Heres the implementation of the Chat class with the requested variables and methods import javautil public class Chat private List String members priv... View full answer
Get step-by-step solutions from verified subject matter experts
