blooming8

Equalizator - Check

Jun 2nd, 2014
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. public class Check {
  2.  
  3.     public static boolean Input(String strx, String stry, String strz) {
  4.  
  5.         boolean ok = true; // Boolean di controllo degli input
  6.  
  7.         if (strx.equals("0") && stry.equals("0") && strz.equals("0")) { // Caso: Tutti "0"
  8.             JOptionPane.showMessageDialog(null, "Non puoi mettere tutti 0!", "ERRORE", JOptionPane.ERROR_MESSAGE);
  9.             ok = false;
  10.         } else if (strx.equals("") || stry.equals("") || strz.equals("")) { // Caso: Tutti i campi vuoti
  11.             JOptionPane.showMessageDialog(null, "Se un valore è nullo devi inserire 0!", "ERRORE", JOptionPane.ERROR_MESSAGE);
  12.             ok = false;
  13.         } else {
  14.             try {
  15.                 Double.parseDouble(strx);
  16.                 Double.parseDouble(stry);
  17.                 Double.parseDouble(strz);
  18.             } catch (NumberFormatException e){
  19.                 JOptionPane.showMessageDialog(null, "Non puoi inserire tutte lettere!", "ERRORE", JOptionPane.ERROR_MESSAGE);
  20.         ok = false;
  21.             }
  22.         }
  23.         return ok;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment