pragma solidity ^0.4.2; contract Prasham { /* Assumption : There are 1000 employees in company */ enum Status { ABSENT,HALD_DAY,PRESENT } struct Employee { uint256 id ; uint inTime ; Status isPresent ; } Employee[1000] public employees ; // userAddress -> Status //mapping(address -> Status ) ; function employeIn (uint256 RFID ) public returns(uint) { employees[RFID] = Employee(RFID,block.timestamp,Status.ABSENT) ; return employees[RFID].inTime ; } function employeeExit( uint256 RFID ) public returns(Status) { uint exitTime = block.timestamp ; uint workManShip = exitTime - employees[RFID].inTime ; if( workManShip < 1 ) { employees[RFID].isPresent = Status.ABSENT ; } if(workManShip >=1 && workManShip < 4 ){ employees[RFID].isPresent = Status.HALD_DAY ; } if(workManShip >=8 ) { employees[RFID].isPresent = Status.PRESENT ; } return employees[RFID].isPresent ; } }
0.4.18