Created
May 12, 2023 20:27
-
-
Save lclpedro/05722a11a514e4b79f044ab27cb9028f to your computer and use it in GitHub Desktop.
instagram: @codandonapratica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Animal interface { | |
FazerSom() string | |
} | |
type Cachorro struct{} | |
func (c Cachorro) FazerSom() string { | |
return "🐶 Woof.. Woof.." | |
} | |
type Gato struct{} | |
func (g Gato) FazerSom() string { | |
return "🐯 Meow.. Meow.." | |
} | |
type Leao struct{} | |
func (l Leao) FazerSom() string { | |
return "🦁 Rrrrroooar.. Rrrrroooar.." | |
} | |
func FazerSom(a Animal) { | |
fmt.Println() | |
fmt.Println(a.FazerSom()) | |
fmt.Println() | |
} | |
func main() { | |
cachorro := Cachorro{} | |
FazerSom(cachorro) | |
gato := Gato{} | |
FazerSom(gato) | |
leao := Leao{} | |
FazerSom(leao) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment