-
Notifications
You must be signed in to change notification settings - Fork 4
/
7_Structs.sol
34 lines (28 loc) · 1015 Bytes
/
7_Structs.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
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.10;
contract Structs_in_solidity {
struct Attendence {
string name;
bool isPresent;
}
// State Variable : Stored in sotrage
Attendence public defaultAttendence;
// defining default values for the instance of Attendence struct:
constructor () {
defaultAttendence = Attendence({
name: "Unknown",
isPresent: false
});
}
Attendence[] public attendence;
function getAttendenceList (string memory _name, bool _isPresent) public returns (Attendence[] memory) {
// Local Variable: Stored in memory
Attendence memory studentAttendence = Attendence ({name: _name, isPresent: _isPresent});
attendence.push(studentAttendence);
return attendence;
}
function updateAttendence (uint _index, bool _isPresent) public returns (Attendence memory) {
attendence[_index].isPresent = _isPresent;
return attendence[_index];
}
}