-
Notifications
You must be signed in to change notification settings - Fork 0
/
Attendence.sol
52 lines (42 loc) · 1.06 KB
/
Attendence.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
pragma solidity >= 0.7.0 <0.8.0 ;
pragma experimental ABIEncoderV2 ;
contract Attendance
{
int[] rollno ;
mapping(address => int) Adminl ;
mapping(int => string) Student ;
address owner ;
constructor()
{
owner = msg.sender ;
Adminl[msg.sender] = 1;
}
struct Student1
{
int rollno ;
string name ;
int attendance ;
}
mapping(int => Student1) students ;
modifier onlyOwner
{
require(Adminl[msg.sender] == 1);
_;
}
function addStudent( int256 _rollno ,string memory _name,int _attendance) public onlyOwner
{
students[ _rollno] = Student1(_rollno,_name,_attendance) ;
}
function viewAttendance(int _rollno ) view public returns(Student1 memory)
{
return students[_rollno];
}
function addAttendance(int _rollno) public onlyOwner
{
students[_rollno].attendance+=1 ;
}
function addAdmin(address adr) public onlyOwner
{
Adminl[adr] = 1 ;
}
}