Skip to content

Commit

Permalink
Remove unused exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezee1015 committed Dec 4, 2023
1 parent 985eeb7 commit ff68108
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 170 deletions.
2 changes: 1 addition & 1 deletion Truco_Java/src/truco_java/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String sendIrAlMazo () throws IOException {
return receiveMessage();
}

public void throwCard(int posCard) throws IOException{
public void throwCard(int posCard) {
sendMessage("throw " + String.valueOf(posCard));
}
}
18 changes: 2 additions & 16 deletions Truco_Java/src/truco_java/ClientMultiplayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,7 @@ protected void backAction (ActionEvent e) {
effects.setFile("src/truco_java/musica/botonMenu.wav", 1);
effects.play();
if(dialogResult == JOptionPane.YES_OPTION){
try {
client.sendWithdraw();
} catch (Exception ex) {
connectionBackground.setIcon(new ImageIcon("src/truco_java/fondos/turnoError.png"));
JOptionPane.showMessageDialog(null, "Ha sucedido un error al enviar el mensaje: " + ex.getMessage());
effects.setFile("src/truco_java/musica/botonMenu.wav", 1);
effects.play();
}
client.sendWithdraw();
playMenu.setVisible(true);
window.dispose();
if(chat!=null) chat.dispose();
Expand Down Expand Up @@ -885,14 +878,7 @@ public void run(){
}
};
thread1.start();
try {
client.sendPerson(PlayMenu.playerNumber+1, nombre);
} catch (Exception e) {
connectionBackground.setIcon(new ImageIcon("src/truco_java/fondos/turnoError.png"));
JOptionPane.showMessageDialog(null, "Ha sucedido un error en la conexión: " + e.getMessage());
effects.setFile("src/truco_java/musica/botonMenu.wav", 1);
effects.play();
}
client.sendPerson(PlayMenu.playerNumber+1, nombre);
pointsBackground.setIcon(getImageIcon("src/truco_java/puntaje/bg"+ opponentNumber +".png", 100, 150, false));
break;
default:
Expand Down
13 changes: 9 additions & 4 deletions Truco_Java/src/truco_java/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import javax.swing.JOptionPane;

public abstract class Connection {
protected int PORT = 1234;
Expand Down Expand Up @@ -62,24 +63,28 @@ protected void sendMessage(String message){
try {
reconnect();
sendMessage(message);
return;
} catch (Exception ex) { }
}
JOptionPane.showMessageDialog(null, "Ha sucedido un error al enviar o recibir el mensaje: " + e.getMessage());
Truco_Java.effects.setFile("src/truco_java/musica/botonMenu.wav", 1);
Truco_Java.effects.play();
}
}

public void sendEnvido(ArrayList<Integer> envidosDeclared, int trucoLevel, int enabledToRetrucar) throws IOException{
public void sendEnvido(ArrayList<Integer> envidosDeclared, int trucoLevel, int enabledToRetrucar) {
sendMessage("envido " + String.valueOf(envidosDeclared.get(envidosDeclared.size()-1)) + " " + trucoLevel + " " + enabledToRetrucar);
}

public void sendTruco(int trucoLevel, int enabledToRetrucar) throws IOException{
public void sendTruco(int trucoLevel, int enabledToRetrucar) {
sendMessage("truco " + trucoLevel + " " + enabledToRetrucar);
}

public void sendPerson(int number, String name) throws IOException{
public void sendPerson(int number, String name) {
sendMessage("player " + number + " " + name);
}

public void sendWithdraw() throws IOException{
public void sendWithdraw() {
sendMessage("withdraw");
}

Expand Down
4 changes: 2 additions & 2 deletions Truco_Java/src/truco_java/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void killServer(){
cs = null;
}

public void sendKill(boolean oponentWins) throws IOException{
public void sendKill(boolean oponentWins) {
sendMessage("kill " + oponentWins);
}

Expand Down Expand Up @@ -71,7 +71,7 @@ public void updateInfo(int sizePlayerCards, SetOfCards playedPlayerCards,SetOfCa
sendMessage(message);
}

public void printMessage(String message) throws IOException{
public void printMessage(String message) {
sendMessage("print " + message);
}
}
Loading

0 comments on commit ff68108

Please sign in to comment.