-
Notifications
You must be signed in to change notification settings - Fork 0
/
14-Interface1.sol
52 lines (42 loc) · 1.51 KB
/
14-Interface1.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IRegistration {
struct Person {
string name;
string surname;
uint no;
}
function getCount() external view returns (uint);
function getPerson(uint _no) external view returns (Person memory);
function registerPerson(string memory _name, string memory _surname, uint _no) external;
}
contract RegisterStudent is IRegistration {
uint studentCount;
mapping(uint => Person) students;
function getCount() external view override returns (uint) {
return studentCount;
}
function registerPerson(string memory _name, string memory _surname, uint _no) external override {
students[_no] = Person({name:_name, surname:_surname, no:_no });
studentCount++;
}
function getPerson(uint _no) external view override returns (Person memory) {
Person memory student = students[_no];
return student;
}
}
contract RegisterTeacher is IRegistration {
uint teacherCount;
mapping(uint => Person) teachers;
function getCount() external view override returns (uint) {
return teacherCount;
}
function registerPerson(string memory _name, string memory _surname, uint _no) external override {
teachers[_no] = Person({name:_name, surname:_surname, no:_no });
teacherCount++;
}
function getPerson(uint _no) external view override returns (Person memory) {
Person memory student = teachers[_no];
return student;
}
}