COMP2396
Loading...
Searching...
No Matches
DailyAdviceServer Class Reference
Collaboration diagram for DailyAdviceServer:

Public Member Functions

String getAdvice ()
 
void go ()
 

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

Definition at line 4 of file DailyAdviceServer.java.

Member Function Documentation

◆ getAdvice()

String DailyAdviceServer.getAdvice ( )
inline

Definition at line 8 of file DailyAdviceServer.java.

8 {
9 int random = (int) (Math.random() * adviceList.length);
10 return adviceList[random];
11 }

Referenced by go().

Here is the caller graph for this function:

◆ go()

void DailyAdviceServer.go ( )
inline

Definition at line 18 of file DailyAdviceServer.java.

18 {
19 try {
20 serverSock = new ServerSocket(5000);
21 while (true) {
22 Socket sock = serverSock.accept();
23 PrintWriter writer = new PrintWriter(sock.getOutputStream());
24 String advice = getAdvice();
25 writer.println(advice);
26 writer.close();
27 System.out.println(advice);
28 }
29 } catch (Exception ex) {
30 ex.printStackTrace();
31 }
32 } // close go

References getAdvice().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

static void DailyAdviceServer.main ( String[] args)
inlinestatic

Definition at line 13 of file DailyAdviceServer.java.

References go().

Here is the call graph for this function:

The documentation for this class was generated from the following file: