From fcbff695f0a5a64756001280ce574fd1abeb43e4 Mon Sep 17 00:00:00 2001 From: Chris McArthur Date: Sun, 7 Oct 2018 22:22:37 -0400 Subject: [PATCH] missed a unsaved file --- .../RecordsManagment/src/Models/Record.java | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Assignments/JavaRmi/RecordsManagment/src/Models/Record.java b/Assignments/JavaRmi/RecordsManagment/src/Models/Record.java index 42a6c6f..20a3415 100644 --- a/Assignments/JavaRmi/RecordsManagment/src/Models/Record.java +++ b/Assignments/JavaRmi/RecordsManagment/src/Models/Record.java @@ -61,9 +61,41 @@ public String getHashIndex() { return Character.toString(Character.toLowerCase(m_LastName.charAt(0))); } - public void manipulateFeild(Record record, Feild feild, Object newValue) throws Exception { + public void manipulateFeild(Feild feild, Object newValue) throws Exception { + switch (feild) { + case FIRST_NAME: + if (newValue.getClass() == String.class) { + setFirstName((String) newValue); + } else { + throw new Exception("Invalid paramater"); + } + break; + case LAST_NAME: + if (newValue.getClass() == String.class) { + setLastName((String) newValue); + } else { + throw new Exception("Invalid paramater"); + } + break; + case EMPLOYEE_ID: + if (newValue.getClass() == Integer.class) { + setEmployeeNumber((int) newValue); + } else { + throw new Exception("Invalid paramater"); + } + break; + case MAIL_ID: + if (newValue.getClass() == String.class) { + setMailId((String) newValue); + } else { + throw new Exception("Invalid paramater"); + } + break; + default: + throw new Exception("Unknow Feild"); + } } - + private void setFirstName(String firstName) { m_FirstName = firstName; }