-
Notifications
You must be signed in to change notification settings - Fork 603
Expand file tree
/
Copy pathmyfirstcontract.sol
More file actions
81 lines (47 loc) · 1.27 KB
/
myfirstcontract.sol
File metadata and controls
81 lines (47 loc) · 1.27 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
interface Regulator {
function checkValue(uint amount) external returns (bool);
function loan() external returns (bool);
}
contract Bank is Regulator{
uint private value;
constructor(uint amount) {
value = amount;
}
function deposit(uint amount) public {
value += amount;
}
function withdrawel(uint amount) public {
if (checkValue(amount)){
value -= amount;
}
}
function balance() public view returns (uint) {
return value;
}
// Override
function checkValue(uint amount) public override view returns (bool) {
return value > amount;
}
function loan() public override view returns (bool) {
return value > 0;
}
}
contract myfirstcontract is Bank(10) {
// Opposite of Java - private String firstName;
string private name;
uint private age;
function setName(string memory newName) public {
name = newName;
}
function getName() public view returns (string memory) {
return name;
}
function setAge(uint newAge) public {
age = newAge;
}
function getAge() public view returns (uint) {
return age;
}
}