Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 members - A list of all members in the chat.

2. List files - A list of all files in the chat.

3. HashMap message - A list of all messages in the chat.

 

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

Step: 1

Heres the implementation of the Chat class with the requested variables and methods import javautil public class Chat private List String members priv... 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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Programming questions

Question

Please make it fast 2 3 1

Answered: 1 week ago

Question

Solve the integral:

Answered: 1 week ago

Question

What is meant by Non-programmed decision?

Answered: 1 week ago

Question

What are the different techniques used in decision making?

Answered: 1 week ago

Question

What is a form?

Answered: 1 week ago

Question

How do views relate to security?

Answered: 1 week ago