|
| 1 | +import "DogShelter" |
| 2 | + |
1 | 3 | // A simple Person contract |
2 | 4 | // |
3 | 5 | // reference: https://developers.flow.com/cadence/language/contracts |
4 | 6 | pub contract Person { |
5 | 7 | // declaration of a public variable |
6 | 8 | pub var name: String |
7 | | - // declaration of a private variable, reference: https://developers.flow.com/cadence/language/access-control#access-control |
8 | | - access(self) var happy: Bool |
| 9 | + pub var dog: @DogShelter.Dog |
9 | 10 |
|
10 | 11 | // initialization method for our contracts, this gets run on deployment |
11 | 12 | init() { |
12 | 13 | self.name = "Alice" |
13 | | - self.happy = true |
14 | | - } |
15 | | - |
16 | | - pub fun hello(): String { |
17 | | - log("saying hello") // when we log we can see the log in the emulator output, helpful for debugging |
18 | | - |
19 | | - return self.happy == true ? "😍 Hello!" : "😤 Go away!" |
20 | | - } |
21 | | - |
22 | | - pub fun WhoAmI(): String { |
23 | | - return "I am ".concat(self.name) |
| 14 | + self.dog <- DogShelter.addoptDog(name: "Fifi") |
24 | 15 | } |
25 | 16 |
|
26 | | - pub fun changeMyMood() { |
27 | | - self.happy = !self.happy |
| 17 | + pub fun sayHello(): String { |
| 18 | + return "Hello, my name is ".concat(self.name) |
28 | 19 | } |
29 | 20 |
|
30 | 21 | // create a new friendship resource |
|
36 | 27 | // |
37 | 28 | // read more about this unique and powerful Cadence feature here https://developers.flow.com/cadence/language/resources |
38 | 29 | pub resource Friendship { |
39 | | - pub var strength: UInt64 |
40 | | - |
41 | | - init() { |
42 | | - self.strength = unsafeRandom() |
| 30 | + init() {} |
| 31 | + pub fun yaay() { |
| 32 | + log("such a nice friend") // we can log to output, useful on emualtor for debugging |
43 | 33 | } |
44 | 34 | } |
45 | 35 | } |
|
0 commit comments