learn_go/cards/deck.go

24 lines
425 B
Go
Raw Normal View History

2022-02-06 22:13:36 +01:00
package main
import "fmt"
type deck []string
func (d deck) print() {
for i, card := range d {
fmt.Println(i, card)
}
}
func newDeck() deck {
cards := deck{}
cardSuits := []string{"Spades", "Diamonds", "Hearts", "Clubs"}
cardValues := []string{"Ace", "Two", "Three", "Four"}
for _, suite := range cardSuits {
for _, value := range cardValues {
cards = append(cards, value+" of "+suite)
}
}
return cards
}