-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathMyContract.sol
More file actions
64 lines (49 loc) · 1.28 KB
/
MyContract.sol
File metadata and controls
64 lines (49 loc) · 1.28 KB
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
61
62
63
64
// SPDX-License-Identifier: MIT
//
// https://cryptomarketpool.com/inheritance
pragma solidity ^0.8.0;
interface Regulator {
function checkValue(uint256 amount) external returns (bool);
function loan() external returns (bool);
}
contract Bank is Regulator {
uint256 private value;
address private owner;
constructor(uint256 amount) {
value = amount;
owner = msg.sender;
}
function deposit(uint256 amount) public {
value += amount;
}
function withdraw(uint256 amount) public {
if (checkValue(amount)) {
value -= amount;
}
}
function balance() public view returns (uint256) {
return value;
}
function checkValue(uint256 amount) public view returns (bool) {
return amount >= value;
}
function loan() public view returns (bool) {
return value > 0;
}
}
contract MyContract is Bank(10) {
string private name;
uint256 private age;
function setName(string memory newName) public {
name = newName;
}
function getName() public view returns (string memory) {
return name;
}
function setAge(uint256 newAge) public {
age = newAge;
}
function getAge() public view returns (uint256) {
return age;
}
}