SlideShare a Scribd company logo
1 of 1
Download to read offline
Why the code is not running? I didn't get any main function to run it import java.util.ArrayList;
import java.util.HashMap; import java.util.List; import java.util.Map; public class Server { private
List<Member> members = new ArrayList<>(); private Member coordinator; public void
addMember(Member member) { if (members.isEmpty()) { coordinator = member;
coordinator.informCoordinator(); } else { member.receiveMembers(getMemberDetails());
broadcastMessage(member.getName() + " has joined the group."); } members.add(member); }
public void removeMember(Member member) { members.remove(member); if
(member.equals(coordinator)) { coordinator = null; electNewCoordinator(); }
broadcastMessage(member.getName() + " has left the group."); } private void
electNewCoordinator() { if (members.size() > 0) { coordinator = members.get(0);
broadcastMessage(coordinator.getName() + " is now the new coordinator.");
coordinator.informCoordinator(); } } public List<Member> getMembers() { return members; }
private Map<String, MemberDetails> getMemberDetails() { Map<String, MemberDetails>
memberDetails = new HashMap<>(); for (Member member : members) {
memberDetails.put(member.getName(), new MemberDetails(member.getIpAddress(),
member.getPort())); } return memberDetails; } public void broadcastMessage(String message) { for
(Member member : members) { member.receiveBroadcastMessage(message); } } public void
sendPrivateMessage(Member sender, String recipientName, String message) { for (Member
member : members) { if (member.getName().equals(recipientName)) {
member.receivePrivateMessage(sender.getName(), message); return; } } } public void
handleUnresponsiveMember(Member member) { members.remove(member);
broadcastMessage(member.getName() + " is unresponsive."); } } public class Member { private
String name; private String ipAddress; private int port; private List<MemberDetails> members =
new ArrayList<>(); private Server server; public Member(String name, String ipAddress, int port) {
this.name = name; this.ipAddress = ipAddress; this.port = port; } public void joinGroup(Server
server) { this.server = server; server.addMember(this); } public void leaveGroup() {
server.removeMember(this); } public void receiveMembers(Map<String, MemberDetails>
memberDetails) { members.clear(); members.addAll(memberDetails.values()); } public void
informCoordinator() { System.out.println("I am the new coordinator."); } public void
receiveBroadcastMessage(String message) { System.out.println("[" + name + "] " + message); }
public void receivePrivateMessage(String senderName, String message) {
System.out.println("[Private message from " + senderName + " to " + name + "] " + message); }
public String getName() { return name; } public String getIpAddress() { return ipAddress; } public
int getPort() { return port; } } class MemberDetails { private String ipAddress; private int port; public
MemberDetails(String ipAddress, int port) { this.ipAddress = ipAddress; this.port = port; } public
String getIpAddress() { return ipAddress; } public int getPort() { return port; } }

More Related Content

Similar to Why the code is not running I didnt get any main function .pdf

Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented NetworkingMostafa Amer
 
Angular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmidAngular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmidAmrita Chopra
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfShaiAlmog1
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfkostikjaylonshaewe47
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programingwahyuseptiansyah
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdfasarudheen07
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfarrowmobile
 
Java осень 2012 лекция 2
Java осень 2012 лекция 2Java осень 2012 лекция 2
Java осень 2012 лекция 2Technopark
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfmichardsonkhaicarr37
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Kuldeep Jain
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeDaniel Wellman
 

Similar to Why the code is not running I didnt get any main function .pdf (20)

2 a networkflow
2 a networkflow2 a networkflow
2 a networkflow
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
 
Angular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmidAngular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmid
 
java sockets
 java sockets java sockets
java sockets
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
 
Week 12 code
Week 12 codeWeek 12 code
Week 12 code
 
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdfImplement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
Implement a queue using a linkedlist (java)SolutionLinkedQueue.pdf
 
201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing201913046 wahyu septiansyah network programing
201913046 wahyu septiansyah network programing
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
Manual tecnic sergi_subirats
Manual tecnic sergi_subiratsManual tecnic sergi_subirats
Manual tecnic sergi_subirats
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
 
Java осень 2012 лекция 2
Java осень 2012 лекция 2Java осень 2012 лекция 2
Java осень 2012 лекция 2
 
Groovy
GroovyGroovy
Groovy
 
in this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdfin this assignment you are asked to write a simple driver program an.pdf
in this assignment you are asked to write a simple driver program an.pdf
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
oop objects_classes
oop objects_classesoop objects_classes
oop objects_classes
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 

More from abyssiniaimpex1

Determine whether the following problem involves a permutati.pdf
Determine whether the following problem involves a permutati.pdfDetermine whether the following problem involves a permutati.pdf
Determine whether the following problem involves a permutati.pdfabyssiniaimpex1
 
3 Results from the National Health and Nutrition Examinatio.pdf
3 Results from the National Health and Nutrition Examinatio.pdf3 Results from the National Health and Nutrition Examinatio.pdf
3 Results from the National Health and Nutrition Examinatio.pdfabyssiniaimpex1
 
6 Diversity still plays a role of a tack on in the study .pdf
6 Diversity still plays a role of a tack on in the study .pdf6 Diversity still plays a role of a tack on in the study .pdf
6 Diversity still plays a role of a tack on in the study .pdfabyssiniaimpex1
 
14 You and your friends race to the gym after school and w.pdf
14 You and your friends race to the gym after school and w.pdf14 You and your friends race to the gym after school and w.pdf
14 You and your friends race to the gym after school and w.pdfabyssiniaimpex1
 
Uno de los miembros del comit Joanne Hader est exasperad.pdf
Uno de los miembros del comit Joanne Hader est exasperad.pdfUno de los miembros del comit Joanne Hader est exasperad.pdf
Uno de los miembros del comit Joanne Hader est exasperad.pdfabyssiniaimpex1
 
Using the following national income accounting data compute.pdf
Using the following national income accounting data compute.pdfUsing the following national income accounting data compute.pdf
Using the following national income accounting data compute.pdfabyssiniaimpex1
 
Which list all that apply of the common justifications of .pdf
Which list all that apply of the common justifications of .pdfWhich list all that apply of the common justifications of .pdf
Which list all that apply of the common justifications of .pdfabyssiniaimpex1
 
The Tech section in Forbes magazine reported that the crimi.pdf
The Tech section in Forbes magazine reported that the crimi.pdfThe Tech section in Forbes magazine reported that the crimi.pdf
The Tech section in Forbes magazine reported that the crimi.pdfabyssiniaimpex1
 
QUESTION 1 Second mouth A Eumetazoans Molting animals .pdf
QUESTION 1  Second mouth A Eumetazoans Molting animals .pdfQUESTION 1  Second mouth A Eumetazoans Molting animals .pdf
QUESTION 1 Second mouth A Eumetazoans Molting animals .pdfabyssiniaimpex1
 
Problem 4 20 pts Given the following function and main pr.pdf
Problem 4 20 pts Given the following function and main pr.pdfProblem 4 20 pts Given the following function and main pr.pdf
Problem 4 20 pts Given the following function and main pr.pdfabyssiniaimpex1
 
Problems on P functions Find the value of each Integral 1 0.pdf
Problems on P functions Find the value of each Integral 1 0.pdfProblems on P functions Find the value of each Integral 1 0.pdf
Problems on P functions Find the value of each Integral 1 0.pdfabyssiniaimpex1
 
Need help finding pvalue with Statskey graph Thank you The.pdf
Need help finding pvalue with Statskey graph Thank you The.pdfNeed help finding pvalue with Statskey graph Thank you The.pdf
Need help finding pvalue with Statskey graph Thank you The.pdfabyssiniaimpex1
 
1 Was it a wise move by Netflix to move from a distribution.pdf
1 Was it a wise move by Netflix to move from a distribution.pdf1 Was it a wise move by Netflix to move from a distribution.pdf
1 Was it a wise move by Netflix to move from a distribution.pdfabyssiniaimpex1
 
Homework 1 Generate vehicle plate numbers Assume a New Yor.pdf
Homework 1  Generate vehicle plate numbers Assume a New Yor.pdfHomework 1  Generate vehicle plate numbers Assume a New Yor.pdf
Homework 1 Generate vehicle plate numbers Assume a New Yor.pdfabyssiniaimpex1
 
How to Turn a Group of Strangers Into a Team In the age of v.pdf
How to Turn a Group of Strangers Into a Team In the age of v.pdfHow to Turn a Group of Strangers Into a Team In the age of v.pdf
How to Turn a Group of Strangers Into a Team In the age of v.pdfabyssiniaimpex1
 
I am trying to implement an ArrayStack but only can get 4 te.pdf
I am trying to implement an ArrayStack but only can get 4 te.pdfI am trying to implement an ArrayStack but only can get 4 te.pdf
I am trying to implement an ArrayStack but only can get 4 te.pdfabyssiniaimpex1
 
Hello Please help me with the following questions in order .pdf
Hello Please help me with the following questions in order .pdfHello Please help me with the following questions in order .pdf
Hello Please help me with the following questions in order .pdfabyssiniaimpex1
 
Conceptual Leadership Questionnaire Pg 2022 Take Question.pdf
Conceptual Leadership Questionnaire Pg 2022 Take Question.pdfConceptual Leadership Questionnaire Pg 2022 Take Question.pdf
Conceptual Leadership Questionnaire Pg 2022 Take Question.pdfabyssiniaimpex1
 
El peligro de una sola historia Quiero resaltar que uno de .pdf
El peligro de una sola historia  Quiero resaltar que uno de .pdfEl peligro de una sola historia  Quiero resaltar que uno de .pdf
El peligro de una sola historia Quiero resaltar que uno de .pdfabyssiniaimpex1
 
El 1 de enero de 2020 Lennon Industries tena acciones en c.pdf
El 1 de enero de 2020 Lennon Industries tena acciones en c.pdfEl 1 de enero de 2020 Lennon Industries tena acciones en c.pdf
El 1 de enero de 2020 Lennon Industries tena acciones en c.pdfabyssiniaimpex1
 

More from abyssiniaimpex1 (20)

Determine whether the following problem involves a permutati.pdf
Determine whether the following problem involves a permutati.pdfDetermine whether the following problem involves a permutati.pdf
Determine whether the following problem involves a permutati.pdf
 
3 Results from the National Health and Nutrition Examinatio.pdf
3 Results from the National Health and Nutrition Examinatio.pdf3 Results from the National Health and Nutrition Examinatio.pdf
3 Results from the National Health and Nutrition Examinatio.pdf
 
6 Diversity still plays a role of a tack on in the study .pdf
6 Diversity still plays a role of a tack on in the study .pdf6 Diversity still plays a role of a tack on in the study .pdf
6 Diversity still plays a role of a tack on in the study .pdf
 
14 You and your friends race to the gym after school and w.pdf
14 You and your friends race to the gym after school and w.pdf14 You and your friends race to the gym after school and w.pdf
14 You and your friends race to the gym after school and w.pdf
 
Uno de los miembros del comit Joanne Hader est exasperad.pdf
Uno de los miembros del comit Joanne Hader est exasperad.pdfUno de los miembros del comit Joanne Hader est exasperad.pdf
Uno de los miembros del comit Joanne Hader est exasperad.pdf
 
Using the following national income accounting data compute.pdf
Using the following national income accounting data compute.pdfUsing the following national income accounting data compute.pdf
Using the following national income accounting data compute.pdf
 
Which list all that apply of the common justifications of .pdf
Which list all that apply of the common justifications of .pdfWhich list all that apply of the common justifications of .pdf
Which list all that apply of the common justifications of .pdf
 
The Tech section in Forbes magazine reported that the crimi.pdf
The Tech section in Forbes magazine reported that the crimi.pdfThe Tech section in Forbes magazine reported that the crimi.pdf
The Tech section in Forbes magazine reported that the crimi.pdf
 
QUESTION 1 Second mouth A Eumetazoans Molting animals .pdf
QUESTION 1  Second mouth A Eumetazoans Molting animals .pdfQUESTION 1  Second mouth A Eumetazoans Molting animals .pdf
QUESTION 1 Second mouth A Eumetazoans Molting animals .pdf
 
Problem 4 20 pts Given the following function and main pr.pdf
Problem 4 20 pts Given the following function and main pr.pdfProblem 4 20 pts Given the following function and main pr.pdf
Problem 4 20 pts Given the following function and main pr.pdf
 
Problems on P functions Find the value of each Integral 1 0.pdf
Problems on P functions Find the value of each Integral 1 0.pdfProblems on P functions Find the value of each Integral 1 0.pdf
Problems on P functions Find the value of each Integral 1 0.pdf
 
Need help finding pvalue with Statskey graph Thank you The.pdf
Need help finding pvalue with Statskey graph Thank you The.pdfNeed help finding pvalue with Statskey graph Thank you The.pdf
Need help finding pvalue with Statskey graph Thank you The.pdf
 
1 Was it a wise move by Netflix to move from a distribution.pdf
1 Was it a wise move by Netflix to move from a distribution.pdf1 Was it a wise move by Netflix to move from a distribution.pdf
1 Was it a wise move by Netflix to move from a distribution.pdf
 
Homework 1 Generate vehicle plate numbers Assume a New Yor.pdf
Homework 1  Generate vehicle plate numbers Assume a New Yor.pdfHomework 1  Generate vehicle plate numbers Assume a New Yor.pdf
Homework 1 Generate vehicle plate numbers Assume a New Yor.pdf
 
How to Turn a Group of Strangers Into a Team In the age of v.pdf
How to Turn a Group of Strangers Into a Team In the age of v.pdfHow to Turn a Group of Strangers Into a Team In the age of v.pdf
How to Turn a Group of Strangers Into a Team In the age of v.pdf
 
I am trying to implement an ArrayStack but only can get 4 te.pdf
I am trying to implement an ArrayStack but only can get 4 te.pdfI am trying to implement an ArrayStack but only can get 4 te.pdf
I am trying to implement an ArrayStack but only can get 4 te.pdf
 
Hello Please help me with the following questions in order .pdf
Hello Please help me with the following questions in order .pdfHello Please help me with the following questions in order .pdf
Hello Please help me with the following questions in order .pdf
 
Conceptual Leadership Questionnaire Pg 2022 Take Question.pdf
Conceptual Leadership Questionnaire Pg 2022 Take Question.pdfConceptual Leadership Questionnaire Pg 2022 Take Question.pdf
Conceptual Leadership Questionnaire Pg 2022 Take Question.pdf
 
El peligro de una sola historia Quiero resaltar que uno de .pdf
El peligro de una sola historia  Quiero resaltar que uno de .pdfEl peligro de una sola historia  Quiero resaltar que uno de .pdf
El peligro de una sola historia Quiero resaltar que uno de .pdf
 
El 1 de enero de 2020 Lennon Industries tena acciones en c.pdf
El 1 de enero de 2020 Lennon Industries tena acciones en c.pdfEl 1 de enero de 2020 Lennon Industries tena acciones en c.pdf
El 1 de enero de 2020 Lennon Industries tena acciones en c.pdf
 

Recently uploaded

How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 

Recently uploaded (20)

How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 

Why the code is not running I didnt get any main function .pdf

  • 1. Why the code is not running? I didn't get any main function to run it import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Server { private List<Member> members = new ArrayList<>(); private Member coordinator; public void addMember(Member member) { if (members.isEmpty()) { coordinator = member; coordinator.informCoordinator(); } else { member.receiveMembers(getMemberDetails()); broadcastMessage(member.getName() + " has joined the group."); } members.add(member); } public void removeMember(Member member) { members.remove(member); if (member.equals(coordinator)) { coordinator = null; electNewCoordinator(); } broadcastMessage(member.getName() + " has left the group."); } private void electNewCoordinator() { if (members.size() > 0) { coordinator = members.get(0); broadcastMessage(coordinator.getName() + " is now the new coordinator."); coordinator.informCoordinator(); } } public List<Member> getMembers() { return members; } private Map<String, MemberDetails> getMemberDetails() { Map<String, MemberDetails> memberDetails = new HashMap<>(); for (Member member : members) { memberDetails.put(member.getName(), new MemberDetails(member.getIpAddress(), member.getPort())); } return memberDetails; } public void broadcastMessage(String message) { for (Member member : members) { member.receiveBroadcastMessage(message); } } public void sendPrivateMessage(Member sender, String recipientName, String message) { for (Member member : members) { if (member.getName().equals(recipientName)) { member.receivePrivateMessage(sender.getName(), message); return; } } } public void handleUnresponsiveMember(Member member) { members.remove(member); broadcastMessage(member.getName() + " is unresponsive."); } } public class Member { private String name; private String ipAddress; private int port; private List<MemberDetails> members = new ArrayList<>(); private Server server; public Member(String name, String ipAddress, int port) { this.name = name; this.ipAddress = ipAddress; this.port = port; } public void joinGroup(Server server) { this.server = server; server.addMember(this); } public void leaveGroup() { server.removeMember(this); } public void receiveMembers(Map<String, MemberDetails> memberDetails) { members.clear(); members.addAll(memberDetails.values()); } public void informCoordinator() { System.out.println("I am the new coordinator."); } public void receiveBroadcastMessage(String message) { System.out.println("[" + name + "] " + message); } public void receivePrivateMessage(String senderName, String message) { System.out.println("[Private message from " + senderName + " to " + name + "] " + message); } public String getName() { return name; } public String getIpAddress() { return ipAddress; } public int getPort() { return port; } } class MemberDetails { private String ipAddress; private int port; public MemberDetails(String ipAddress, int port) { this.ipAddress = ipAddress; this.port = port; } public String getIpAddress() { return ipAddress; } public int getPort() { return port; } }