-
Notifications
You must be signed in to change notification settings - Fork 0
/
myFirstContract.sol
58 lines (45 loc) · 1.12 KB
/
myFirstContract.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
pragma solidity ^0.4.7;
interface Regulator {
function checkValue(uint amount) returns (bool);
function loan() returns(bool);
}
contract Bank is Regulator {
uint private value;
function Bank(uint amount) {
value = amount;
}
function deposit(uint amount) {
value += amount;
}
function withdraw(uint amount) {
if (checkValue(amount)) {
value -= amount;
}
}
function balance() returns (uint) {
return value;
}
function checkValue(uint amount) returns(bool) {
return amount >= value;
}
function loan() returns (bool) {
return value > 0;
}
}
//any functionality that exists in bank will now exist in myFirstContract
contract myFirstContract is Bank(10) {
string private name;
uint private age;
function setName(string newName) {
name = newName;
}
function getName() returns (string) {
return name;
}
function setAge(uint newAge) {
age = newAge;
}
function getAge() returns (uint) {
return age;
}
}