-
Notifications
You must be signed in to change notification settings - Fork 0
/
animal_rescue.go
43 lines (38 loc) · 1006 Bytes
/
animal_rescue.go
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
package main
// AnimalRescue represents an organization
// consisting of Adopter and Adoptee Relationships
type AnimalRescue struct {
Adopters map[int]*Adopter
Adoptees map[int]*Adoptee
Adoptions map[int]*Adoption
PetPreferences map[int]*PetPreference
AdopterSeq func() int
AdopteeSeq func() int
AdoptionSeq func() int
PetPreferenceSeq func() int
}
func (ar *AnimalRescue) init() {
adopters := make(map[int]*Adopter, 0)
adoptees := make(map[int]*Adoptee, 0)
adoptions := make(map[int]*Adoption, 0)
petPreferences := make(map[int]*PetPreference, 0)
adopterSeq := intSeq()
adopteeSeq := intSeq()
adoptionSeq := intSeq()
petPrefSeq := intSeq()
ar.Adopters = adopters
ar.Adoptees = adoptees
ar.Adoptions = adoptions
ar.PetPreferences = petPreferences
ar.AdopterSeq = adopterSeq
ar.AdopteeSeq = adopteeSeq
ar.AdoptionSeq = adoptionSeq
ar.PetPreferenceSeq = petPrefSeq
}
func intSeq() func() int {
i := 0
return func() int {
i++
return i
}
}