Problem Statement:
Design an employee swap in swap out system. The system will have a machine which records the swap in and swap out. The user can also login in a portal where he can check his swap in /swap out time. He can correct his time also.
There will be managers for employee who can check the entry for all the employees which are under them and correct their subordinates timings also.
Similarly, a HR person can only view every Employee's records.
I chalked out the following skeleton. I am new to design and would like any pointers on how to approach such problems.
class User{
String name;
String designation;
int id;
}
class AccessGroup{
int priority;
String name;
Boolean read;
Boolean write;
//Setter - Getter methods
}
static class AccessManagement{
HashSet<String, PriorityQueue<AccessGroup> accessControlTable;
public void addUser(User u, AccessGroup g);
public void addUserToGroup(User u, AccessGroup g);
public void removeUser(User u);
public void removeUserFromGroup(User u, AccessGroup g);
public AccessGroup getPriorityAccessGroupForUser(User u);
public PriorityQueue<AccessGroup> getUserGroups(User u);
public boolean isValidUser(User u);
public boolean hasReadPermission(User u);
public boolean hasWritePermission(User u);
}
class Mediator{
String url="";
public List<Records> getRecords(User u);
public void updateRecordForUser(User u, Record r, Value v){
if(!AccessManagement.isValidUser(u))
throw Exception();
if(AccessManagement.hasWritePermission(u)){
try{
Connection conn = DriverManager.getConnection(url);
Statement statement = conn.createStatement();
statement.executeQuery("Update r in TimeStamps where id= u.id");
}
catch(Exception e){
//Do something
}
}
}
}
HashSet<T, E>
. because the javaHashSet
does have only one type parameter.HashSet<T>
\$\endgroup\$HashMap
\$\endgroup\$