-
Notifications
You must be signed in to change notification settings - Fork 0
/
inheritance.sol
60 lines (42 loc) · 1.2 KB
/
inheritance.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
53
54
55
56
57
58
59
60
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract elbow{
uint private age = 24;
function bend() public pure virtual returns(string memory){
return "Bending";
}
function getAge() public view returns(uint){
return age;
}
}
contract leftArm is elbow{
function raise() public virtual returns(string memory){
return string.concat("Left Arm is ",bend());
}
}
contract rightArm is elbow{
function raise() public virtual returns(string memory){
return string.concat("Right Arm is ",bend());
}
}
contract knee is elbow{
function getBend() public pure returns(string memory){
return super.bend();
}
function kick() public pure returns(string memory){
return "kicking";
}
}
contract person is leftArm,rightArm{
function raise() public pure override(leftArm,rightArm) returns(string memory){
return string.concat("Both arms are", bend());
}
}
contract alien is rightArm, knee{
function bend() public pure override returns(string memory){
return "flying";
}
function fly() public pure returns(string memory){
return string.concat(kick(),bend());
}
}