Advertisement
Nick-O-Rama

testInherit

Feb 16th, 2015
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1.  
  2. public class testInherit {
  3.  
  4.     public static void main(String[] args) {
  5.         String name = "Bobert Clah";
  6.         String id = "111-M";
  7.         String hire = "12/12/12";
  8.         int shift = 1;
  9.         double rate = 20.75;
  10.         if (validateId(id))
  11.         {
  12.             ProductionWorker emp1 = new ProductionWorker(name, id, hire, shift, rate);
  13.         }
  14.        
  15.         Employee emp1;
  16.         System.out.println(emp1.getId());
  17.  
  18.     }
  19.    
  20.     public static boolean validateId(String id)
  21.     {
  22.         boolean valid = true;
  23.         if (!(id.length() == 5))
  24.             valid = false;
  25.         else{
  26.         for (int i = 0; i < 3; i++)
  27.         {
  28.             if (!Character.isDigit(id.charAt(i)))
  29.                 valid = false;
  30.             else if (!(id.charAt(3) == '-'))
  31.                 valid = false;
  32.             else if (id.charAt(4) < 'A' || id.charAt(4) > 'M')
  33.                 valid = false;
  34.         }
  35.         }
  36.         return valid;
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement