Skip to content

Commit 5e0d9e3

Browse files
authored
Update Person.cdc
1 parent e11b518 commit 5e0d9e3

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

cadence/contracts/Person.cdc

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1+
import "DogShelter"
2+
13
// A simple Person contract
24
//
35
// reference: https://developers.flow.com/cadence/language/contracts
46
pub contract Person {
57
// declaration of a public variable
68
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
910

1011
// initialization method for our contracts, this gets run on deployment
1112
init() {
1213
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")
2415
}
2516

26-
pub fun changeMyMood() {
27-
self.happy = !self.happy
17+
pub fun sayHello(): String {
18+
return "Hello, my name is ".concat(self.name)
2819
}
2920

3021
// create a new friendship resource
@@ -36,10 +27,9 @@
3627
//
3728
// read more about this unique and powerful Cadence feature here https://developers.flow.com/cadence/language/resources
3829
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
4333
}
4434
}
4535
}

0 commit comments

Comments
 (0)