Skip to content

Commit

Permalink
Added function of newDeck
Browse files Browse the repository at this point in the history
  • Loading branch information
gandhi-jay committed Dec 1, 2017
1 parent 776f617 commit fb86de7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions go_stephen_grider/code/03_cards_deck/deck.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,24 @@ import (
// which is a slice of string.
type deck []string

// Any variable with Type deck in app
// can call this variable.
func (d deck) print() {
for i, card := range d {
fmt.Println(i, card)
}
}

func newDeck() deck {
cards := deck{}
cardSuits := []string{"Diamonds", "Spades", "Hearts", "Clubs"}
cardValues := []string{"Ace", "Two", "Three", "Four", "Five"}

for _, cardSuit := range cardSuits {
for _, cardValue := range cardValues {
cards = append(cards, cardValue+" of "+cardSuit)
}
}

return cards
}

0 comments on commit fb86de7

Please sign in to comment.