diff --git a/go_stephen_grider/code/03_cards_deck/deck.go b/go_stephen_grider/code/03_cards_deck/deck.go new file mode 100644 index 0000000..167de7a --- /dev/null +++ b/go_stephen_grider/code/03_cards_deck/deck.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" +) + +// Create a new type of deck +// which is a slice of string. +type deck []string + +func (d deck) print() { + for i, card := range d { + fmt.Println(i, card) + } +} diff --git a/go_stephen_grider/code/03_cards_deck/main.go b/go_stephen_grider/code/03_cards_deck/main.go new file mode 100644 index 0000000..085aac7 --- /dev/null +++ b/go_stephen_grider/code/03_cards_deck/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" +) + +func main() { + cards := deck{newCard(), "Seven of Spades"} + + fmt.Println(cards) + + cards.print() +} + +func newCard() string { + return "Ace of Spades" +}