Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Check {
- public static boolean Input(String strx, String stry, String strz) {
- boolean ok = true; // Boolean di controllo degli input
- if (strx.equals("0") && stry.equals("0") && strz.equals("0")) { // Caso: Tutti "0"
- JOptionPane.showMessageDialog(null, "Non puoi mettere tutti 0!", "ERRORE", JOptionPane.ERROR_MESSAGE);
- ok = false;
- } else if (strx.equals("") || stry.equals("") || strz.equals("")) { // Caso: Tutti i campi vuoti
- JOptionPane.showMessageDialog(null, "Se un valore è nullo devi inserire 0!", "ERRORE", JOptionPane.ERROR_MESSAGE);
- ok = false;
- } else {
- try {
- Double.parseDouble(strx);
- Double.parseDouble(stry);
- Double.parseDouble(strz);
- } catch (NumberFormatException e){
- JOptionPane.showMessageDialog(null, "Non puoi inserire tutte lettere!", "ERRORE", JOptionPane.ERROR_MESSAGE);
- ok = false;
- }
- }
- return ok;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment