Created
December 7, 2022 23:00
-
-
Save hamzamuric/53cfc7c289ab8af8228c2e91fc4e235b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.ServerSocket; | |
import java.net.Socket; | |
import java.util.Scanner; | |
import java.io.PrintWriter; | |
import java.io.IOException; | |
class Server { | |
public static void main(String[] args) throws IOException { | |
int host = 3000; | |
ServerSocket serverSocket = new ServerSocket(host); | |
Socket socket = serverSocket.accept(); | |
System.out.println("Uspostavljena konekcija"); | |
Scanner in = new Scanner(socket.getInputStream()); | |
PrintWriter out = new PrintWriter(socket.getOutputStream(), true); | |
while (true) { | |
String[] odgovori = in.nextLine().split(","); | |
String licnost; | |
if (odgovori[0].equals("Da") && odgovori[1].equals("Da")) { | |
licnost = "Introvertna licnost"; | |
} else if (odgovori[0].equals("Ne") && odgovori[1].equals("Ne")) { | |
licnost = "Ekstrovertna licnost"; | |
} else if ( | |
odgovori[0].equals("Ne") && odgovori[1].equals("Da") || | |
odgovori[0].equals("Da") && odgovori[1].equals("Ne")) { | |
licnost = "Umerena licnost"; | |
} else { | |
licnost = "Pogresni odgovori"; | |
} | |
out.println(licnost); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment