Browse Source

Refactor: use yoda notation to get error in case of mistyping

remotes/origin/feature/client/exchange-messages-between-client-server
Alena Bandarovich 11 months ago
parent
commit
58c5ad97fc
  1. 6
      src/main/java/ChatClient.java

6
src/main/java/ChatClient.java

@ -20,7 +20,7 @@ public class ChatClient extends JFrame implements KeyListener {
super("Chat"); super("Chat");
address = JOptionPane.showInputDialog("bitte IP-Adresse"); address = JOptionPane.showInputDialog("bitte IP-Adresse");
if (address != null) {
if (null != address) {
receiveMessages(); receiveMessages();
} }
} }
@ -47,8 +47,8 @@ public class ChatClient extends JFrame implements KeyListener {
private void receiveMessages() { private void receiveMessages() {
try { try {
connectionToServer = new Socket(address, Constants.PORT); connectionToServer = new Socket(address, Constants.PORT);
fromServerReader = new BufferedReader(new InputStreamReader(connectionToServer.getInputStream()));
toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream()));
fromServerReader = new BufferedReader(new InputStreamReader(connectionToServer.getInputStream()));
toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream()));
initGui(); initGui();

Loading…
Cancel
Save