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 | package main import ( "fmt" "rand" "time" ) type Person struct { Gender string BackLength int FrontLength int } func (p *Person) hasMullet() bool { return p.BackLength > p.FrontLength } func (p *Person) addressMullet() { for p.BackLength > p.FrontLength { p.BackLength-- fmt.Println("Decrementing the mullet length!") } fmt.Println("Mullet cured!") } func main() { fmt.Println("Welcome to the MULLET Program.\n") fmt.Println("Creating a new genome to work with...\n") person := new(Person) rand.Seed(time.LocalTime()) fmt.Println("Person created.") person.Gender = "Male" person.BackLength = rand.Intn(25) person.FrontLength = rand.Intn(25) fmt.Println("----------------------------------------") fmt.Println("Gender:", person.Gender) fmt.Println("BackLength:", person.BackLength) fmt.Println("FrontLength:", person.FrontLength) if person.hasMullet() { fmt.Println("This guy has a mullet!") person.addressMullet() } else { fmt.Println("This guy does not have a mullet.") } } |
cGFja2FnZSBtYWluCgppbXBvcnQgKAoJImZtdCIKCSJyYW5kIgoJInRpbWUiCikKCnR5cGUgUGVyc29uIHN0cnVjdCB7CglHZW5kZXIgc3RyaW5nCglCYWNrTGVuZ3RoIGludAoJRnJvbnRMZW5ndGggaW50Cn0KCmZ1bmMgKHAgKlBlcnNvbikgaGFzTXVsbGV0KCkgYm9vbCB7CglyZXR1cm4gcC5CYWNrTGVuZ3RoID4gcC5Gcm9udExlbmd0aAp9CgpmdW5jIChwICpQZXJzb24pIGFkZHJlc3NNdWxsZXQoKSB7Cglmb3IgcC5CYWNrTGVuZ3RoID4gcC5Gcm9udExlbmd0aCB7CgkJcC5CYWNrTGVuZ3RoLS0KCQlmbXQuUHJpbnRsbigiRGVjcmVtZW50aW5nIHRoZSBtdWxsZXQgbGVuZ3RoISIpCgl9CglmbXQuUHJpbnRsbigiTXVsbGV0IGN1cmVkISIpCn0KCmZ1bmMgbWFpbigpIHsKCWZtdC5QcmludGxuKCJXZWxjb21lIHRvIHRoZSBNVUxMRVQgUHJvZ3JhbS5cbiIpCglmbXQuUHJpbnRsbigiQ3JlYXRpbmcgYSBuZXcgZ2Vub21lIHRvIHdvcmsgd2l0aC4uLlxuIikKCXBlcnNvbiA6PSBuZXcoUGVyc29uKQoJcmFuZC5TZWVkKHRpbWUuTG9jYWxUaW1lKCkpCglmbXQuUHJpbnRsbigiUGVyc29uIGNyZWF0ZWQuIikKCXBlcnNvbi5HZW5kZXIgPSAiTWFsZSIKCXBlcnNvbi5CYWNrTGVuZ3RoID0gcmFuZC5JbnRuKDI1KQoJcGVyc29uLkZyb250TGVuZ3RoID0gcmFuZC5JbnRuKDI1KQoJZm10LlByaW50bG4oIi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0iKQoJZm10LlByaW50bG4oIkdlbmRlcjoiLCBwZXJzb24uR2VuZGVyKQoJZm10LlByaW50bG4oIkJhY2tMZW5ndGg6IiwgcGVyc29uLkJhY2tMZW5ndGgpCglmbXQuUHJpbnRsbigiRnJvbnRMZW5ndGg6IiwgcGVyc29uLkZyb250TGVuZ3RoKQoJCglpZiBwZXJzb24uaGFzTXVsbGV0KCkgewoJCWZtdC5QcmludGxuKCJUaGlzIGd1eSBoYXMgYSBtdWxsZXQhIikKCQlwZXJzb24uYWRkcmVzc011bGxldCgpCgl9IGVsc2UgewoJCWZtdC5QcmludGxuKCJUaGlzIGd1eSBkb2VzIG5vdCBoYXZlIGEgbXVsbGV0LiIpCgl9Cn0K
prog.go:31: cannot use time.LocalTime() (type *time.Time) as type int64 in function argument
-
result: Compilation error (maybe you wish to see an example for Go)



