Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class testInherit {
- public static void main(String[] args) {
- String name = "Bobert Clah";
- String id = "111-M";
- String hire = "12/12/12";
- int shift = 1;
- double rate = 20.75;
- if (validateId(id))
- {
- ProductionWorker emp1 = new ProductionWorker(name, id, hire, shift, rate);
- }
- Employee emp1;
- System.out.println(emp1.getId());
- }
- public static boolean validateId(String id)
- {
- boolean valid = true;
- if (!(id.length() == 5))
- valid = false;
- else{
- for (int i = 0; i < 3; i++)
- {
- if (!Character.isDigit(id.charAt(i)))
- valid = false;
- else if (!(id.charAt(3) == '-'))
- valid = false;
- else if (id.charAt(4) < 'A' || id.charAt(4) > 'M')
- valid = false;
- }
- }
- return valid;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement