-
Notifications
You must be signed in to change notification settings - Fork 0
/
contract.sol
40 lines (33 loc) · 907 Bytes
/
contract.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
//SPDX-License-Identifier: GPL-3.0
pragma solidity >= 0.7.0 <0.9.0;
contract Box
{
uint private userCount;
struct person
{
string name;
string adress;
uint cnic;
uint dob;
uint treeNumber;
}
mapping(uint => person) public user;
function addDetails(string memory _name, string memory _adress, uint _cnic, uint _dob, uint _treeN) public
{
userCount++;
user[userCount] = person(_name, _adress, _cnic, _dob, _treeN);
}
function DetailsById(uint _id) public view returns(person memory)
{
return user[_id];
}
function getAllDetails() public view returns(person[] memory)
{
person[] memory getDetails = new person[](userCount);
for(uint i = 0; i < userCount; i++)
{
getDetails[i] = user[i+1];
}
return getDetails;
}
}