diff --git a/achyut/pom.xml b/achyut/pom.xml
index eee3d5a..794dead 100644
--- a/achyut/pom.xml
+++ b/achyut/pom.xml
@@ -6,4 +6,11 @@
1.0.0
achyut
+
+
+ mysql
+ mysql-connector-java
+ 5.1.33
+
+
\ No newline at end of file
diff --git a/achyut/src/main/java/com/lftechnology/appinterfaces/AppUserInterface.java b/achyut/src/main/java/com/lftechnology/appinterfaces/AppUserInterface.java
new file mode 100644
index 0000000..d76b59c
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/appinterfaces/AppUserInterface.java
@@ -0,0 +1,14 @@
+package com.lftechnology.appinterfaces;
+
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.User;
+/**
+ * Interface for authentication for the application users
+ * @author achyut
+ *
+ */
+public interface AppUserInterface {
+
+ public Employee authenticate(User user);
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/appinterfaces/EmployeeInterface.java b/achyut/src/main/java/com/lftechnology/appinterfaces/EmployeeInterface.java
new file mode 100644
index 0000000..75657f8
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/appinterfaces/EmployeeInterface.java
@@ -0,0 +1,24 @@
+package com.lftechnology.appinterfaces;
+
+import com.lftechnology.entities.Employee;
+import java.sql.ResultSet;
+/**
+ * An Interface to define the signatures for the employee management
+ * @author achyut
+ *
+ */
+public interface EmployeeInterface {
+
+ public boolean isUsernameExists(String username);
+
+ public int addEmployee(Employee e);
+
+ public int deleteEmployee(Employee e);
+
+ public int terminateEmployee(Employee e);
+
+ public Employee editEmployeeDetails(Employee e);
+
+ public ResultSet searchEmployee(Employee e);
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/controller/EmployeeController.java b/achyut/src/main/java/com/lftechnology/controller/EmployeeController.java
new file mode 100644
index 0000000..d5246b2
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/controller/EmployeeController.java
@@ -0,0 +1,105 @@
+
+package com.lftechnology.controller;
+
+import java.sql.ResultSet;
+import com.lftechnology.entities.Role;
+import com.lftechnology.service.EmployeeService;
+import com.lftechnology.service.ServiceFactory;
+import com.lftechnology.entities.Employee;
+
+/**
+ * Controller to managed the employee
+ * @author achyut
+ *
+ */
+public class EmployeeController {
+
+ /**
+ * For First time setup on the superadmin
+ * @author achyut
+ * @return void
+ */
+ public void prepareInitialUser(){
+ EmployeeService ed = ServiceFactory.getEmployeeService();
+ if(!ed.isUsernameExists("superadmin")){
+ Employee e = new Employee();
+ e.setUsername("superadmin");
+ e.setPassword("superadmin");
+ e.setDepartment("FHF");
+ e.setAddress("Kalanki Syuchatar");
+ e.setFullName("Achyut Dahal");
+ e.setIsTerminated(false);
+ e.setRole(Role.ADMIN);
+ ed.addEmployee(e);
+ }
+
+ }
+
+ /**
+ * Add an employee object to database
+ * @param employee
+ * @return int
+ */
+ public int addEmployee(Employee employee) {
+ int employeeAdded = 0;
+ EmployeeService ed = ServiceFactory.getEmployeeService();
+ employeeAdded = ed.addEmployee(employee);
+
+ return employeeAdded;
+ }
+
+ /**
+ * Terminate an employee
+ * @param employee
+ * @return int
+ */
+ public int terminateEmployee(Employee employee) {
+ int employeeTerminated = 0;
+ EmployeeService emplSerObj = ServiceFactory.getEmployeeService();
+ employeeTerminated = emplSerObj.terminateEmployee(employee);
+ return employeeTerminated;
+ }
+
+ /**
+ * Delete an employee from the system
+ * @param em
+ * @return int
+ */
+ public int deleteEmployee(Employee employee) {
+ int employeeDeleted = 0;
+ EmployeeService emplSerObj = ServiceFactory.getEmployeeService();
+ employeeDeleted = emplSerObj.deleteEmployee(employee);
+ return employeeDeleted;
+ }
+
+ /**
+ * View an employee in the system
+ * @param employee
+ * @return ResultSet
+ */
+ public ResultSet viewEmployee(Employee employee) {
+ ResultSet rs = null;
+ EmployeeService emplSerObj = ServiceFactory.getEmployeeService();
+ rs = emplSerObj.searchEmployee(employee);
+ return rs;
+ }
+
+ /**
+ * Update the profile of an employee
+ * @param employee
+ * @return Employee
+ */
+ public Employee editEmployeeDetails(Employee employee) {
+ EmployeeService emplServiceObj = ServiceFactory.getEmployeeService();
+ String userNameFormat = "[a-zA-z][a-zA-z0-9._@]+";
+ if (employee.getUsername().length() != 0 && !(employee.getUsername().matches(userNameFormat))) {
+ System.out.println("\n\t\tUsername Cannot contain extra characters\n");
+ return employee;
+ }
+ return emplServiceObj.editEmployeeDetails(employee);
+
+ }
+
+
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/controller/UserController.java b/achyut/src/main/java/com/lftechnology/controller/UserController.java
new file mode 100644
index 0000000..f09b9e7
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/controller/UserController.java
@@ -0,0 +1,68 @@
+
+package com.lftechnology.controller;
+
+import java.util.Scanner;
+import com.lftechnology.service.UserService;
+import com.lftechnology.service.ServiceFactory;
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.User;
+import com.lftechnology.entities.Role;
+import com.lftechnology.view.UserMenu;
+/**
+ * Controller for handling the user actions
+ * @author achyut
+ *
+ */
+
+public class UserController {
+
+ /**
+ * Validate and login a user
+ * @param user
+ * @param scan
+ */
+ public void login(User user, Scanner scan) {
+ Employee employee = new Employee();
+ UserService ls = ServiceFactory.getLoginService();
+
+ employee = ls.authenticate(user);
+
+ if (employee.getId() == 0) {
+ System.out.println("\nLogin Failed. No username and password matched");
+ } else {
+ System.out.format("Welcome %s", employee.getFullName());
+ UserMenu userMenu = new UserMenu();
+ if (employee.getRole().equals(Role.ADMIN)) {
+ userMenu.displayAdminMenu(employee, scan);
+ } else {
+ userMenu.displayUserMenu(employee, scan);
+ }
+ }
+
+ }
+
+ /**
+ * Prepare a user for logout making the user GUEST
+ * @param employee
+ * @param sc
+ * @return Employee
+ */
+ public static Employee logOut(Employee employee, Scanner sc) {
+ System.out.println("\nYou Wanna Sign Out?");
+ System.out.println("tyes = 1\t\tno = 2");
+
+ int check = Integer.parseInt(sc.nextLine());
+ if (check == 1) {
+ employee.setRole(Role.GUEST);
+ employee.setId(0);
+ employee.setUsername("");
+ employee.setPassword("");
+ employee.setIsTerminated(true);
+ employee.setFullName("");
+ employee.setAddress("");
+ employee.setDepartment("");
+ }
+ return employee;
+ }
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/dao/DaoFactory.java b/achyut/src/main/java/com/lftechnology/dao/DaoFactory.java
new file mode 100644
index 0000000..7bf7ccf
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/dao/DaoFactory.java
@@ -0,0 +1,23 @@
+
+package com.lftechnology.dao;
+
+
+public class DaoFactory {
+
+ private DaoFactory() {
+
+ }
+
+ public static UserDao getLoginDao() {
+
+ return new UserDao();
+ }
+
+ public static EmployeeDao getEmployeeDao() {
+
+ return new EmployeeDao();
+ }
+
+
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/dao/DbAdapter.java b/achyut/src/main/java/com/lftechnology/dao/DbAdapter.java
new file mode 100644
index 0000000..179fafb
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/dao/DbAdapter.java
@@ -0,0 +1,48 @@
+package com.lftechnology.dao;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.Properties;
+
+/**
+ * DBAdapter for Mysql
+ * @author achyut
+ *
+ */
+public class DbAdapter {
+
+ private DbAdapter() {
+
+ }
+
+ /**
+ * Get a MYSQL JDBC Connection
+ * @return Connection
+ */
+ public static Connection setConnection() {
+
+ Properties prop = new Properties();
+ InputStream input = null;
+
+ Connection connection = null;
+ try{
+ input = new FileInputStream("src/main/java/com/lftechnology/dao/dbconfig.properties");
+ prop.load(input);
+ String username = prop.getProperty("dbuser");
+ String password = prop.getProperty("dbpass");
+ String url = prop.getProperty("dburl");
+ connection = DriverManager.getConnection(url, username, password);
+
+ input.close();
+ } catch(FileNotFoundException fnf){
+ System.out.println("File not found");
+ } catch (Exception e) {
+
+ System.out.println("Couldn't connect to database ="+e.getMessage());
+ }
+ return connection;
+ }
+}
diff --git a/achyut/src/main/java/com/lftechnology/dao/EmployeeDao.java b/achyut/src/main/java/com/lftechnology/dao/EmployeeDao.java
new file mode 100644
index 0000000..c19af08
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/dao/EmployeeDao.java
@@ -0,0 +1,244 @@
+
+package com.lftechnology.dao;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import com.lftechnology.appinterfaces.EmployeeInterface;
+import com.lftechnology.entities.Employee;
+
+import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException;
+
+/**
+ * An implementation for database operation of an employee
+ * @author achyut
+ *
+ */
+
+public class EmployeeDao implements EmployeeInterface {
+
+
+
+ /**
+ * Checks if the username exists on the system
+ * @author achyut
+ * @param boolean
+ */
+ @Override
+ public boolean isUsernameExists(String name) {
+
+ ResultSet rs = null;
+ StringBuilder sql = null;
+ Connection con = DbAdapter.setConnection();
+ if (con == null) {
+ System.out.println("\n Cannot connect to database");
+ return false;
+ }
+ PreparedStatement preparedStmt = null;
+
+ sql = new StringBuilder("select * from employee where username= ?");
+
+
+ try {
+ preparedStmt = con.prepareStatement(sql.toString());
+ preparedStmt.setString(1, name);
+ rs = preparedStmt.executeQuery();
+ if(!rs.next())
+ {
+ return false;
+ } else{
+ return true;
+ }
+
+ } catch (SQLException e) {
+ System.out.println("Error has been encountered:"+e.getMessage());
+ return true;
+ }
+
+ }
+
+ /**
+ * Add an employee object to database
+ * @author achyut
+ * @return int count of employee added
+ */
+ @Override
+ public int addEmployee(Employee e) {
+
+ Connection con = DbAdapter.setConnection();
+ int count = 0;
+ if (con == null) {
+ System.out.println("\n Cannot connect to database");
+ return count;
+ }
+ PreparedStatement preparedStmt = null;
+ String sql = "insert into employee (username,password,is_terminated,fullname,department,address,role) values(?,?,?,?,?,?,?)";
+ try {
+ preparedStmt = con.prepareStatement(sql);
+
+ preparedStmt.setString(1, e.getUsername());
+ preparedStmt.setString(2, e.getPassword());
+ preparedStmt.setBoolean(3, e.getIsTerminated());
+ preparedStmt.setString(4, e.getFullName());
+ preparedStmt.setString(5, e.getDepartment());
+ preparedStmt.setString(6, e.getAddress());
+ preparedStmt.setString(7, e.getRole().toString());
+
+ count = preparedStmt.executeUpdate();
+
+ } catch (MySQLIntegrityConstraintViolationException e1) {
+ System.out.println("The Username Already Taken");
+ } catch (SQLException sq) {
+ System.out.println("Error has been encountered:"+sq.getMessage());
+ }
+
+ return count;
+ }
+
+ /**
+ * Deletes an employee from the system
+ * @author achyut
+ * @return int
+ */
+
+ @Override
+ public int deleteEmployee(Employee e) {
+ Connection con = DbAdapter.setConnection();
+ int count = 0;
+ if (con == null) {
+ System.out.println("\n Cannot connect to database");
+ return count;
+ }
+ PreparedStatement preparedStmt = null;
+ String sql = "delete from employee where fullname = ? ";
+ try {
+ preparedStmt = con.prepareStatement(sql);
+
+ preparedStmt.setString(1, e.getFullName());
+ count = preparedStmt.executeUpdate();
+
+ } catch (SQLException sq) {
+ System.out.println("Error has been encountered:"+sq.getMessage());
+ }
+ return count;
+ }
+
+ /**
+ * Search an employee on the system
+ * @author achyut
+ * @param employee
+ */
+ @Override
+ public ResultSet searchEmployee(Employee employee) {
+
+ ResultSet rs = null;
+ StringBuilder sql = null;
+ Connection con = DbAdapter.setConnection();
+ if (con == null) {
+ System.out.println("\n Cannot connect to database");
+ return rs;
+ }
+ PreparedStatement preparedStmt = null;
+
+ sql = new StringBuilder("select * from employee where 1=1 ");
+ if (!"".equals(employee.getFullName())) {
+ sql.append("and fullname like '");
+ sql.append(employee.getFullName());
+ sql.append("%'");
+ }
+ if (!"".equals(employee.getAddress())) {
+ sql.append(" and address like '");
+ sql.append(employee.getAddress());
+ sql.append("%'");
+ }
+ if (!"".equals(employee.getDepartment())) {
+ sql.append(" and department like '");
+ sql.append(employee.getDepartment());
+ sql.append("%'");
+ }
+
+ try {
+ preparedStmt = con.prepareStatement(sql.toString());
+ rs = preparedStmt.executeQuery();
+
+ } catch (SQLException ex) {
+ System.out.println("Error has been encountered:"+ex.getMessage());
+ }
+
+ return rs;
+ }
+
+ /**
+ * Terminate an employee from the system
+ * @author achyut
+ * @return int
+ */
+ @Override
+ public int terminateEmployee(Employee e) {
+
+ Connection con = DbAdapter.setConnection();
+ int count = 0;
+ if (con == null) {
+ System.out.println("\n Cannot connect to database");
+ return count;
+ }
+ PreparedStatement preparedStmt = null;
+ String sql = "update employee set is_terminated=1 where fullname=? ";
+ try {
+ preparedStmt = con.prepareStatement(sql);
+
+ preparedStmt.setString(1, e.getFullName());
+
+ count = preparedStmt.executeUpdate();
+
+ } catch (SQLException sq) {
+ System.out.println("Error has been encountered:"+sq.getMessage());
+ }
+ return count;
+ }
+
+ /**
+ * Edit the profile of an employee
+ * @author achyut
+ * @param employee
+ */
+
+ @Override
+ public Employee editEmployeeDetails(Employee employee) {
+
+ Connection con = DbAdapter.setConnection();
+ int count = 0;
+ if (con == null) {
+ System.out.println("\n Cannot connect to database");
+ return employee;
+ }
+ PreparedStatement preparedStmt = null;
+ String sql = "update employee set username=?,password=?,fullname=?,department=?,address=? where is_terminated=0 and id=?";
+ try {
+ preparedStmt = con.prepareStatement(sql);
+
+ preparedStmt.setString(1, employee.getUsername());
+ preparedStmt.setString(2, employee.getPassword());
+ preparedStmt.setString(3, employee.getFullName());
+ preparedStmt.setString(4, employee.getDepartment());
+ preparedStmt.setString(5, employee.getAddress());
+ preparedStmt.setInt(6, employee.getId());
+
+ count = preparedStmt.executeUpdate();
+
+ if (count == 0) {
+ System.out.println("The entered data was not updated. Please re-try.");
+ } else {
+ System.out.println("Edit complete..");
+ }
+ } catch (SQLException sq) {
+ System.out.println("Error has been encountered:"+sq.getMessage());
+ }
+ return employee;
+ }
+
+
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/dao/UserDao.java b/achyut/src/main/java/com/lftechnology/dao/UserDao.java
new file mode 100644
index 0000000..224ea41
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/dao/UserDao.java
@@ -0,0 +1,74 @@
+
+package com.lftechnology.dao;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import com.lftechnology.appinterfaces.AppUserInterface;
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.User;
+import com.lftechnology.entities.Role;
+
+/**
+ * Handles the operation for login of the user
+ *
+ * @author achyut
+ *
+ */
+
+public class UserDao implements AppUserInterface {
+
+ /**
+ * Authenticate a user
+ *
+ * @author achyut
+ * @param employee
+ */
+ @Override
+ public Employee authenticate(User user) {
+
+ Employee employee = new Employee();
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+
+ con = DbAdapter.setConnection();
+
+ String sql = "select * from employee where username= ? and password= ? and is_terminated=false";
+ if (con == null) {
+ System.out.println("Cannot connect to database");
+ return employee;
+ }
+
+ try {
+ pst = con.prepareStatement(sql);
+
+ pst.setString(1, user.getUsername());
+ pst.setString(2, user.getPassword());
+
+ rs = pst.executeQuery();
+
+ if (rs.next()) {
+ employee.setId(rs.getInt("id"));
+ employee.setUsername(rs.getString("username"));
+ employee.setPassword(rs.getString("password"));
+ employee.setIsTerminated(rs.getBoolean("is_terminated"));
+ employee.setDepartment(rs.getString("department"));
+ employee.setFullName(rs.getString("fullname"));
+ employee.setAddress(rs.getString("address"));
+ Role ut = Role.valueOf(rs.getString("role"));
+ employee.setRole(ut);
+ } else {
+ employee.setId(0);
+ }
+ con.close();
+ pst.close();
+ rs.close();
+ } catch (SQLException e) {
+ System.out.println("Error has been encountered:" + e.getMessage());
+ }
+ return employee;
+ }
+}
diff --git a/achyut/src/main/java/com/lftechnology/dao/dbconfig.properties b/achyut/src/main/java/com/lftechnology/dao/dbconfig.properties
new file mode 100644
index 0000000..1481a4e
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/dao/dbconfig.properties
@@ -0,0 +1,3 @@
+dbuser=root
+dbpass=achyut@123
+dburl=jdbc:mysql://localhost:3306/employeemgmt
diff --git a/achyut/src/main/java/com/lftechnology/entities/Employee.java b/achyut/src/main/java/com/lftechnology/entities/Employee.java
new file mode 100644
index 0000000..218e955
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/entities/Employee.java
@@ -0,0 +1,57 @@
+package com.lftechnology.entities;
+
+import com.lftechnology.entities.User;
+
+/**
+ * Employee entity on the system
+ * @author achyut
+ *
+ */
+public class Employee extends User {
+
+ private String fullname;
+ private String department;
+ private String address;
+ private Role role;
+
+ public String getFullName() {
+
+ return fullname;
+ }
+
+ public void setFullName(String fullName) {
+
+ this.fullname = fullName;
+ }
+
+ public String getDepartment() {
+
+ return department;
+ }
+
+ public void setDepartment(String department) {
+
+ this.department = department;
+ }
+
+ public String getAddress() {
+
+ return address;
+ }
+
+ public void setAddress(String address) {
+
+ this.address = address;
+ }
+
+ public Role getRole() {
+
+ return role;
+ }
+
+ public void setRole(Role role) {
+
+ this.role = role;
+ }
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/entities/Role.java b/achyut/src/main/java/com/lftechnology/entities/Role.java
new file mode 100644
index 0000000..ccbe4a0
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/entities/Role.java
@@ -0,0 +1,11 @@
+package com.lftechnology.entities;
+
+/**
+ * Role description on the system
+ * @author achyut
+ *
+ */
+public enum Role {
+ ADMIN, USER, GUEST
+}
+
diff --git a/achyut/src/main/java/com/lftechnology/entities/User.java b/achyut/src/main/java/com/lftechnology/entities/User.java
new file mode 100644
index 0000000..308a942
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/entities/User.java
@@ -0,0 +1,55 @@
+package com.lftechnology.entities;
+
+/**
+ * User Entity on the system
+ * @author achyut
+ *
+ */
+public class User {
+
+ private int id;
+ private String username;
+ private String password;
+ private boolean isTerminated;
+
+ public String getUsername() {
+
+ return username;
+ }
+
+ public void setUsername(String username) {
+
+ this.username = username;
+ }
+
+ public int getId() {
+
+ return id;
+ }
+
+ public void setId(int id) {
+
+ this.id = id;
+ }
+
+ public String getPassword() {
+
+ return password;
+ }
+
+ public void setPassword(String password) {
+
+ this.password = password;
+ }
+
+ public boolean getIsTerminated() {
+
+ return isTerminated;
+ }
+
+ public void setIsTerminated(boolean isTerminated) {
+
+ this.isTerminated = isTerminated;
+ }
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/phpjava/package-info.java b/achyut/src/main/java/com/lftechnology/phpjava/package-info.java
deleted file mode 100644
index 8052e30..0000000
--- a/achyut/src/main/java/com/lftechnology/phpjava/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- *
- */
-/**
- * @author bhuwan
- *
- */
-package com.lftechnology.phpjava;
\ No newline at end of file
diff --git a/achyut/src/main/java/com/lftechnology/programs/MultiplierProgram.java b/achyut/src/main/java/com/lftechnology/programs/MultiplierProgram.java
deleted file mode 100644
index 6047746..0000000
--- a/achyut/src/main/java/com/lftechnology/programs/MultiplierProgram.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.lftechnology.programs;
-
-import java.util.Scanner;
-
-public class MultiplierProgram {
-
- private int numberOfMultiple;
- private int firstMultiplier;
- private int secondMultiplier;
- private Scanner scanner;
-
- public MultiplierProgram() {
-
- }
-
- public void run() {
- this.initiateRun();
- System.out.println("->Please Enter the Number of Multiplier");
- scanner = new Scanner(System.in);
- this.numberOfMultiple = scanner.nextInt();
- System.out.println("->Please Enter First Multiplier");
- this.firstMultiplier = scanner.nextInt();
- System.out.println("->Please Enter Second Multiplier");
- this.secondMultiplier = scanner.nextInt();
- int sum = calculateMultiplier();
- System.out.println("Sum of multiple by " + this.firstMultiplier + " and " + this.secondMultiplier + " below "
- + this.numberOfMultiple + "=" + sum);
- this.endRun();
- }
-
- public int calculateMultiplier() {
-
- int sum = 0;
- for (int i = 0; i < this.numberOfMultiple; i++) {
- if ((i % this.firstMultiplier) == 0 || (i % this.secondMultiplier) == 0) {
- sum += i;
- }
- }
- return sum;
- }
-
- public void initiateRun() {
- System.out.println("\n");
- System.out.println("->Executing Multiplier");
-
- }
-
- public void endRun() {
- System.out.println("-----------------------------------------");
- System.out.println("-----------------------------------------\n\n");
- }
-
-}
diff --git a/achyut/src/main/java/com/lftechnology/programs/PalindromeProgram.java b/achyut/src/main/java/com/lftechnology/programs/PalindromeProgram.java
deleted file mode 100644
index 091b5e0..0000000
--- a/achyut/src/main/java/com/lftechnology/programs/PalindromeProgram.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.lftechnology.programs;
-
-import java.util.Scanner;
-
-public class PalindromeProgram {
-
- private String number;
- private Scanner scanner;
-
- public PalindromeProgram() {
-
- }
-
- public void run() {
- this.initiateRun();
- System.out.println("->Please Enter the Number of Multiplier");
- scanner = new Scanner(System.in);
- this.number = scanner.nextLine();
- Boolean isPalindrome = this.isPalindrome();
- if (isPalindrome == true) {
- System.out.println("The number is a palindrome number");
- } else {
- System.out.println("The number is not a palindrome number");
- }
- this.endRun();
- }
-
- public Boolean isPalindrome() {
- String reverse = "";
- int length = this.number.length();
- for (int i = length - 1; i >= 0; i--)
- reverse = reverse + this.number.charAt(i);
-
- if (this.number.equals(reverse))
- return true;
- else
- return false;
-
- }
-
- public void initiateRun() {
- System.out.println("\n");
- System.out.println("->Executing Palindrome Program");
-
- }
-
- public void endRun() {
- System.out.println("-----------------------------------------");
- System.out.println("-----------------------------------------\n\n");
- }
-
-}
diff --git a/achyut/src/main/java/com/lftechnology/programs/SalutationProgram.java b/achyut/src/main/java/com/lftechnology/programs/SalutationProgram.java
deleted file mode 100644
index f3916b8..0000000
--- a/achyut/src/main/java/com/lftechnology/programs/SalutationProgram.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.lftechnology.programs;
-
-import java.util.Scanner;
-
-public class SalutationProgram {
-
- private Scanner fullNameWithSalutationInput;
- private String fullNameWithSalutation;
- private String salutation;
-
- public SalutationProgram() {
-
- }
-
- public void run() {
- this.initiateRun();
- this.askForInput();
- if (this.fullNameWithSalutation.length() <= 0) {
- System.out.println("->Input can't be empty! Enter again");
- this.askForInput();
- }
- this.splitInput();
- System.out.println("Salutation = " + this.salutation);
- System.out.println("FullName = " + this.fullNameWithSalutation);
- this.endRun();
- }
-
- public void initiateRun() {
- System.out.println("\n");
- System.out.println("->Executing Salutation");
- System.out.println("->Please Enter Your Full Name with Salutation (e.g, Mr. John Doe)\n\n");
- }
-
- public void endRun() {
- System.out.println("-----------------------------------------");
- System.out.println("-----------------------------------------\n\n");
- }
-
- public void splitInput() {
- String[] splited = this.fullNameWithSalutation.split("\\s+");
- this.salutation = splited[1];
- }
-
- public void askForInput() {
- fullNameWithSalutationInput = new Scanner(System.in);
- this.fullNameWithSalutation = fullNameWithSalutationInput.nextLine();
- }
-
-}
diff --git a/achyut/src/main/java/com/lftechnology/runner/Executer.java b/achyut/src/main/java/com/lftechnology/runner/Executer.java
deleted file mode 100644
index ab0de40..0000000
--- a/achyut/src/main/java/com/lftechnology/runner/Executer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.lftechnology.runner;
-
-import java.util.Scanner;
-
-public class Executer {
-
- private static Scanner userInput;
- public static int chosenOption;
-
- public static void main(String[] args) {
- Menu menu = new Menu();
- menu.showmenu();
- }
-
- public void askForInputAndRun() {
- /**
- * @todo Check if user input is empty in all the subsequent classes
- */
- userInput = new Scanner(System.in);
- Executer.chosenOption = userInput.nextInt();
- TaskSwitcher taskSwitcher = new TaskSwitcher(Executer.chosenOption);
- taskSwitcher.switchAndRun();
- }
-
-}
diff --git a/achyut/src/main/java/com/lftechnology/runner/Menu.java b/achyut/src/main/java/com/lftechnology/runner/Menu.java
deleted file mode 100644
index d7c87df..0000000
--- a/achyut/src/main/java/com/lftechnology/runner/Menu.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.lftechnology.runner;
-
-public class Menu {
-
- public Menu() {
-
- }
-
- public void showmenu() {
- System.out.println("->Please hit the options below to play with us");
- System.out.println("Options Program");
- System.out.println("1 Salutation");
- System.out.println("2 Multiplier");
- System.out.println("3 Palindrome");
- System.out.println("0 Exit");
- System.out.println("......................");
- System.out.print("->Press the option above to continue: ");
- Executer executor = new Executer();
- executor.askForInputAndRun();
- }
-
-}
diff --git a/achyut/src/main/java/com/lftechnology/runner/TaskSwitcher.java b/achyut/src/main/java/com/lftechnology/runner/TaskSwitcher.java
deleted file mode 100644
index 424a0af..0000000
--- a/achyut/src/main/java/com/lftechnology/runner/TaskSwitcher.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.lftechnology.runner;
-
-import com.lftechnology.programs.MultiplierProgram;
-import com.lftechnology.programs.PalindromeProgram;
-import com.lftechnology.programs.SalutationProgram;
-
-public class TaskSwitcher {
-
- protected int chosenOption;
-
- public TaskSwitcher(int option) {
- this.chosenOption = option;
- }
-
- public void switchAndRun() {
- Menu menu = new Menu();
- switch (this.chosenOption) {
- case 1:
- SalutationProgram salutationProgram = new SalutationProgram();
- salutationProgram.run();
- break;
- case 2:
- MultiplierProgram multiplierProgram = new MultiplierProgram();
- multiplierProgram.run();
- break;
- case 3:
- PalindromeProgram palindromeProgram = new PalindromeProgram();
- palindromeProgram.run();
- break;
- case 0:
- System.out.println("->You are exiting the program now...");
- System.out.println("->Exited");
- System.exit(0);
- default:
- System.out.println("->Invalid Input");
- System.out.println("\n");
- menu.showmenu();
- }
- menu.showmenu();
- }
-}
diff --git a/achyut/src/main/java/com/lftechnology/service/EmployeeService.java b/achyut/src/main/java/com/lftechnology/service/EmployeeService.java
new file mode 100644
index 0000000..d98f322
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/service/EmployeeService.java
@@ -0,0 +1,111 @@
+
+package com.lftechnology.service;
+
+import java.sql.ResultSet;
+import com.lftechnology.appinterfaces.EmployeeInterface;
+import com.lftechnology.dao.DaoFactory;
+import com.lftechnology.dao.EmployeeDao;
+import com.lftechnology.entities.Employee;
+
+/**
+ * Employee service for communicating the underlying dao
+ * @author achyut
+ *
+ */
+public class EmployeeService implements EmployeeInterface {
+
+ /**
+ * Check if the username exists on the system
+ * @author achyut
+ * @param boolean
+ */
+ @Override
+ public boolean isUsernameExists(String username) {
+ EmployeeDao ed = DaoFactory.getEmployeeDao();
+ return ed.isUsernameExists(username);
+ }
+
+ /**
+ * Adds and employee
+ * @author achyut
+ * @return int
+ */
+ @Override
+ public int addEmployee(Employee e) {
+
+ int numberOfUserInserted = 0;
+ EmployeeDao ed = DaoFactory.getEmployeeDao();
+
+ numberOfUserInserted = ed.addEmployee(e);
+
+ return numberOfUserInserted;
+ }
+
+ /**
+ * View the employees
+ * @author achyut
+ * @param ResulSet
+ */
+
+ @Override
+ public ResultSet searchEmployee(Employee e) {
+
+ ResultSet rs = null;
+
+ EmployeeDao ed = DaoFactory.getEmployeeDao();
+ rs = ed.searchEmployee(e);
+
+ return rs;
+ }
+
+ /**
+ * Termniate a user from the system
+ * @author achyut
+ * @param int
+ */
+ @Override
+ public int terminateEmployee(Employee e) {
+
+ EmployeeDao ed = DaoFactory.getEmployeeDao();
+ int numberOfTerminatedUsers = 0;
+
+ numberOfTerminatedUsers = ed.terminateEmployee(e);
+
+ return numberOfTerminatedUsers;
+
+ }
+
+ /**
+ * Delete an employee from the system
+ * @author achyut
+ * @param int
+ */
+ @Override
+ public int deleteEmployee(Employee e) {
+
+ EmployeeDao ed = DaoFactory.getEmployeeDao();
+ int numberOfTerminatedUsers = 0;
+
+ numberOfTerminatedUsers = ed.deleteEmployee(e);
+
+ return numberOfTerminatedUsers;
+
+ }
+
+ /**
+ * Edit an employee profile
+ * @author achyut
+ * @param Employee
+ */
+ @Override
+ public Employee editEmployeeDetails(Employee employee) {
+
+ EmployeeDao ed = DaoFactory.getEmployeeDao();
+
+ return ed.editEmployeeDetails(employee);
+ }
+
+
+
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/service/ServiceFactory.java b/achyut/src/main/java/com/lftechnology/service/ServiceFactory.java
new file mode 100644
index 0000000..6397c9e
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/service/ServiceFactory.java
@@ -0,0 +1,24 @@
+
+package com.lftechnology.service;
+
+/**
+ * A factory class to return specific services
+ * @author achyut
+ *
+ */
+public class ServiceFactory {
+ private ServiceFactory() {
+
+ }
+
+ public static EmployeeService getEmployeeService() {
+
+ return new EmployeeService();
+ }
+
+
+ public static UserService getLoginService() {
+
+ return new UserService();
+ }
+}
diff --git a/achyut/src/main/java/com/lftechnology/service/UserService.java b/achyut/src/main/java/com/lftechnology/service/UserService.java
new file mode 100644
index 0000000..30f5ed0
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/service/UserService.java
@@ -0,0 +1,36 @@
+
+package com.lftechnology.service;
+
+import com.lftechnology.appinterfaces.AppUserInterface;
+import com.lftechnology.dao.DaoFactory;
+import com.lftechnology.dao.UserDao;
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.User;
+
+/**
+ * System service for communicating the loan database layer
+ * @author achyut
+ *
+ */
+public class UserService implements AppUserInterface {
+
+
+ /**
+ * Authenticates a given user
+ * @author achyut
+ * @param user
+ */
+ @Override
+ public Employee authenticate(User user) {
+
+ Employee employee = new Employee();
+ UserDao ld = DaoFactory.getLoginDao();
+ String userNameFormat = "[a-zA-z][a-zA-z0-9._@]+";
+ if (user.getUsername().matches(userNameFormat)) {
+ employee = ld.authenticate(user);
+ } else {
+ employee.setId(-1);
+ }
+ return employee;
+ }
+}
diff --git a/achyut/src/main/java/com/lftechnology/view/App.java b/achyut/src/main/java/com/lftechnology/view/App.java
new file mode 100644
index 0000000..ad773e6
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/view/App.java
@@ -0,0 +1,62 @@
+
+package com.lftechnology.view;
+
+import java.util.Scanner;
+
+import com.lftechnology.controller.EmployeeController;
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.User;
+import com.lftechnology.entities.Role;
+/**
+ * Entry point of employee management system
+ * @author achyut
+ *
+ */
+
+public class App {
+
+ private App() {
+ }
+
+ public static void main(String[] args) {
+ /**
+ * Prepare the initial user for the application if the superadmin user
+ * does't exists on the system
+ */
+ EmployeeController empCtrl = new EmployeeController();
+ empCtrl.prepareInitialUser();
+
+ Scanner scanner = new Scanner(System.in);
+ /** Show login view to the user **/
+ LoginScreen lv=new LoginScreen();
+
+ Employee employee = lv.askForLoginCredential(new User(), scanner);
+ /** Unless the application is exited or have a successful login ask for input*/
+ while (!Role.GUEST.equals(employee.getRole())) {
+
+ employee=lv.askForLoginCredential(new User(), scanner);
+ }
+
+ }
+ /**
+ * Clone the employee
+ * @param e1
+ * @param e2
+ * @return
+ */
+ public static Employee cloneEmployee(Employee e1, Employee e2) {
+
+ e2.setId(e1.getId());
+ e2.setUsername(e1.getUsername());
+ e2.setPassword(e1.getPassword());
+ e2.setFullName(e1.getFullName());
+ e2.setAddress(e1.getAddress());
+ e2.setDepartment(e1.getDepartment());
+ e2.setIsTerminated(e1.getIsTerminated());
+ e2.setRole(e1.getRole());
+ return e2;
+ }
+
+
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/view/EmployeeView.java b/achyut/src/main/java/com/lftechnology/view/EmployeeView.java
new file mode 100644
index 0000000..a0b7270
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/view/EmployeeView.java
@@ -0,0 +1,250 @@
+package com.lftechnology.view;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Scanner;
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.Role;
+
+import com.lftechnology.controller.EmployeeController;
+
+
+public class EmployeeView {
+
+ /**
+ * Add Employee
+ * @author achyut
+ * @param employee
+ * @param sc
+ * @return void
+ */
+ public void addEmployee(Employee employee, Scanner scan) {
+ String userName = null;
+ String password = null;
+ String fullName = null;
+ String department = null;
+ String address = null;
+ int count = 0;
+ boolean isTerminated = false;
+ Role role = null;
+
+ for (;;) {
+ try {
+ System.out.println("\nPlease enter the employee username");
+ userName = scan.nextLine();
+ System.out.println("Pleasse enter the password for the password");
+ password = scan.nextLine();
+ System.out.println("please enter the fullname");
+ fullName = scan.nextLine();
+ System.out.println("Please enter the department");
+ department = scan.nextLine();
+ System.out.println("Please enter the address");
+ address = scan.nextLine();
+ System.out.println("Please enter whether the user is terminated(true/false)");
+ isTerminated = scan.nextBoolean();
+ System.out.println("Please enter the user type::(1=ADMIN/2=EMPLOYEE)");
+ int role2 = scan.nextInt();
+ if (role2 == 1) {
+ role = Role.ADMIN;
+ } else if (role2 == 2) {
+ role = Role.USER;
+ }
+ break;
+ } catch (Exception ex) {
+ System.out.println("Error Occured:"+ex.getMessage());
+ System.out.println("\nPlease re-enter the values.");
+ }
+
+ }
+
+ employee.setAddress(address);
+ employee.setDepartment(department);
+ employee.setFullName(fullName);
+ employee.setIsTerminated(isTerminated);
+ employee.setUsername(userName);
+ employee.setPassword(password);
+ employee.setRole(role);
+
+ EmployeeController ec = new EmployeeController();
+ count = ec.addEmployee(employee);
+
+ if (count == 0) {
+ System.out.println("\n\t\tInsertion failed. No users were added. Please check and enter the data again.");
+ } else {
+ System.out.format( "\nNumber of users added= %s", count);
+ }
+
+ }
+
+ /**
+ * Terminate an employee
+ * @author achyut
+ * @param employee
+ * @param scan
+ * @return void
+ */
+
+ public void terminateEmployee(Employee employee, Scanner scan) {
+
+ String fullName = null;
+ int count = 0;
+ try {
+ System.out.println("\nPlease enter the employee fullname");
+ fullName = scan.nextLine();
+ employee.setFullName(fullName);
+
+ EmployeeController ec = new EmployeeController();
+
+ count = ec.terminateEmployee(employee);
+
+ } catch (Exception ex) {
+ System.out.println("Exception Occured:"+ex.getMessage());
+ }
+ if (count == 0) {
+ System.out.println("\tNo any user to terminate");
+ } else {
+ System.out.format("\nNo of employee terminated = %s", count);
+ }
+ }
+
+ /**
+ * Delete an employee
+ * @author achyut
+ * @param employee
+ * @param scan
+ * @return void
+ */
+ public void deleteEmployee(Employee employee, Scanner scan) {
+
+ String fullName = null;
+ int count = 0;
+ try {
+ System.out.println("\nPlease enter the employee fullname::");
+ fullName = scan.nextLine();
+ employee.setFullName(fullName);
+
+ EmployeeController ec = new EmployeeController();
+
+ count = ec.deleteEmployee(employee);
+
+ } catch (Exception ex) {
+ System.out.println("Exception Occured:"+ex.getMessage());
+ }
+ if (count == 0) {
+ System.out.println("\tNo any user to delete");
+ } else {
+ System.out.format("\nNumbe of User Deleted = %s", count);
+ }
+ }
+
+
+ /**
+ * Search an employee
+ * @author achyut
+ * @param employee
+ * @param scan
+ * @return void
+ */
+ public void searchEmployee(Employee employee, Scanner scan) {
+ ResultSet rs = null;
+ String fullName = null;
+ String department = null;
+ String address = null;
+ try {
+ System.out.println("\nPlease enter the employee fullname");
+ fullName = scan.nextLine();
+
+ System.out.println("Please enter the department");
+ department = scan.nextLine();
+
+ System.out.println("Please enter the address");
+ address = scan.nextLine();
+
+ employee.setFullName(fullName);
+ employee.setAddress(address);
+ employee.setDepartment(department);
+
+ EmployeeController ec = new EmployeeController();
+
+ rs = ec.viewEmployee(employee);
+ if (rs.next()) {
+ System.out.println("...........Search Results...........");
+ System.out.format("%10s%25s%25s%25s%25s%25s", "ID", "USERNAME", "TERMNIATED", "FULLNAME", "DEPARTMENT", "ADDRESS");
+ do {
+ System.out.println("\n");
+ System.out.format("%10s%25s%25s%25s%25s%25s", rs.getInt(1),rs.getString(2), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7));
+
+ } while (rs.next());
+ } else {
+ System.out.println("\nNo Employee Records Matched.");
+ }
+
+ } catch (Exception ex) {
+ System.out.println("\nError has been encountered:"+ ex.getMessage());
+ } finally {
+ try {
+ rs.close();
+ } catch (SQLException e) {
+ System.out.println("\nError has been encountered:"+ e.getMessage());
+ }
+ }
+ }
+
+
+ /**
+ * Edit profile of an employee
+ * @author achyut
+ * @param employee
+ * @param scan
+ * @return Employee
+ */
+ public Employee editEmployeeDetails(Employee employee, Scanner scan) {
+ String userName = null;
+ String password = null;
+ String fullName = null;
+ String department = null;
+ String address = null;
+ try {
+ System.out.println("Enter new username:");
+ userName = scan.nextLine();
+
+ System.out.println("Enter new password:");
+ password = scan.nextLine();
+
+ System.out.println("Enter new fullname:");
+ fullName = scan.nextLine();
+
+ System.out.println("Enter new address:");
+ address = scan.nextLine();
+
+ System.out.println("Enter new department:");
+ department = scan.nextLine();
+
+ if (!("".equals(userName))) {
+ employee.setUsername(userName);
+ }
+ if (!("".equals(password))) {
+ employee.setPassword(password);
+ }
+ if (!("".equals(fullName))) {
+ employee.setFullName(fullName);
+ }
+ if (!("".equals(address))) {
+ employee.setAddress(address);
+ }
+ if (!("".equals(department))) {
+ employee.setDepartment(department);
+ }
+
+
+ EmployeeController empCtrl = new EmployeeController();
+
+ return empCtrl.editEmployeeDetails(employee);
+
+ } catch (Exception ex) {
+ System.out.println("Error has been encountered:"+ ex.getMessage());
+ }
+ return employee;
+ }
+
+}
diff --git a/achyut/src/main/java/com/lftechnology/view/LoginScreen.java b/achyut/src/main/java/com/lftechnology/view/LoginScreen.java
new file mode 100644
index 0000000..a462872
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/view/LoginScreen.java
@@ -0,0 +1,54 @@
+package com.lftechnology.view;
+
+import java.util.Scanner;
+
+import com.lftechnology.controller.UserController;
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.User;
+import com.lftechnology.entities.Role;
+
+public class LoginScreen {
+
+ public Employee askForLoginCredential(User user, Scanner scan) {
+ UserController lc = new UserController();
+ Employee employee = new Employee();
+ do {
+ System.out.println("\n...Employee Management System...");
+ System.out.println("1. Login 2. Any key to exit");
+ System.out.println("Enter your choice");
+ String choice = scan.nextLine();
+ try {
+ if ("1".equals(choice)) {
+
+ String userName = "";
+ String password = "";
+
+ System.out.println("Enter username::");
+
+ userName = scan.nextLine();
+
+ user.setUsername(userName);
+
+ System.out.println("Enter password::");
+ password = scan.nextLine();
+ user.setPassword(password);
+
+ lc.login(user, scan);
+
+ } else {
+ employee.setRole(Role.GUEST);
+ System.out.println("Exiting the application.\n\n");
+
+ }
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ if (Role.GUEST.equals(employee.getRole())) {
+ scan.close();
+ }
+ }
+ } while (!Role.GUEST.equals(employee.getRole()));
+
+ return employee;
+ }
+}
diff --git a/achyut/src/main/java/com/lftechnology/view/UserMenu.java b/achyut/src/main/java/com/lftechnology/view/UserMenu.java
new file mode 100644
index 0000000..f67ff41
--- /dev/null
+++ b/achyut/src/main/java/com/lftechnology/view/UserMenu.java
@@ -0,0 +1,113 @@
+
+package com.lftechnology.view;
+
+import java.util.Scanner;
+import com.lftechnology.controller.UserController;
+import com.lftechnology.entities.Employee;
+import com.lftechnology.entities.Role;
+
+
+public class UserMenu {
+
+ /**
+ * Show Admin Menu
+ * @author achyut
+ * @param employee
+ * @param scan
+ * @return void
+ */
+ public void displayAdminMenu(Employee employee, Scanner scan) {
+ Employee e = new Employee();
+ e = App.cloneEmployee(employee, e);
+ Employee e2 = new Employee();
+ e2 = App.cloneEmployee(e, e2);
+ EmployeeView ev = new EmployeeView();
+ do {
+ try {
+ System.out.println("\n**************************************************");
+ System.out.println("Welcome To Admnistration");
+ System.out.println("1.Add New User/Employee");
+ System.out.println("2.Terminate user");
+ System.out.println("3.Delete user");
+ System.out.println("4.Search user");
+ System.out.println("5.Edit My Profile");
+ System.out.println("6.Sign Out");
+ System.out.println("Please Select An Option From the Menu and hit enter");
+ int choice = Math.abs(Integer.parseInt(scan.nextLine()));
+ switch (choice) {
+ case 1:
+ ev.addEmployee(employee, scan);
+ break;
+ case 2:
+ ev.terminateEmployee(employee, scan);
+ break;
+ case 3:
+ ev.deleteEmployee(employee, scan);
+ break;
+ case 4:
+ ev.searchEmployee(employee, scan);
+ break;
+ case 5:
+ ev.editEmployeeDetails(e, scan);
+ break;
+ case 6:
+ e = UserController.logOut(employee, scan);
+ break;
+
+ default:
+ System.out.println("This is out of menu");
+ break;
+ }
+ } catch (Exception ex) {
+ System.out.println("Encountered and error:"+ex.getMessage());
+ }
+
+ } while (!Role.GUEST.equals(e.getRole()));
+ System.out.println("You have Successfully Signed Out");
+ System.out.println("******************************");
+ }
+
+ /**
+ * Show User Menu
+ * @param employee
+ * @param scan
+ * @return void
+ */
+ public void displayUserMenu(Employee employee, Scanner scan) {
+ EmployeeView ev = new EmployeeView();
+ Employee emp2 = new Employee();
+ emp2 = App.cloneEmployee(employee, emp2);
+
+ Employee e2 = new Employee();
+ e2 = App.cloneEmployee(emp2, e2);
+
+ do {
+ try {
+ System.out.println("\n***************************Welcome to the user panel**********************\n");
+ System.out.println("1.Search/View users");
+ System.out.println("2.Edit personal information");
+ System.out.println("3.Exit");
+ System.out.println("Please Enter your choices");
+ int choice = Math.abs(Integer.parseInt(scan.nextLine()));
+ switch (choice) {
+ case 1:
+ ev.searchEmployee(emp2, scan);
+ break;
+ case 2:
+ e2 = ev.editEmployeeDetails(emp2, scan);
+ break;
+ case 3:
+ emp2 = UserController.logOut(employee, scan);
+ break;
+ default:
+ System.out.println("\n\t\tIncorrect Choice. Please select from the given list");
+ break;
+ }
+
+ } catch (Exception ex) {
+ System.out.println("Error has been encountered:"+ex.getMessage());
+ }
+ } while (!Role.GUEST.equals(emp2.getRole()));
+ System.out.println("Successfully signed out of the application");
+ }
+}