card

package
v0.0.0-...-25c83c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2025 License: ISC Imports: 3 Imported by: 0

Documentation

Overview

Package card models the standard 52-card deck of French playing cards.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	// contains filtered or unexported fields
}

Card represents a playing card in a standard 52-card deck.

func New

func New(s Suit, r Rank) Card

New creates a new playing card given a suit and a rank.

func (Card) Equals

func (c Card) Equals(rhs Card) bool

Equals determines whether or not two cards are the same.

func (Card) Rank

func (c Card) Rank() Rank

Rank returns the rank of a playing card.

func (Card) String

func (c Card) String() string

String Impelements the fmt.Stringer interface.

func (Card) Suit

func (c Card) Suit() Suit

Suit returns the suit of a playing card.

type Deck

type Deck struct {
	// contains filtered or unexported fields
}

Deck represents a standard 52-card deck of French playing cards.

func NewDeck

func NewDeck() *Deck

NewDeck creates a new deck of playing card. The cards in the deck are shuffled.

func (*Deck) Shuffle

func (d *Deck) Shuffle()

Shuffle shuffles the cards in the Deck in O(n) time.

func (*Deck) String

func (d *Deck) String() string

String Impelements the fmt.Stringer interface.

type Game

type Game interface {
	// Name returns the name of the game.
	Name() string
	// Players returns the list of participants involved in the game.
	Players() []Player
}

Game is the abstraction for any game played with standard French playing cards.

type Player

type Player struct {
	ID   int
	Name string
}

Player represents a participant in a game.

func (Player) String

func (p Player) String() string

String Impelements the fmt.Stringer interface.

type Rank

type Rank int

Rank represents one of the thirteen ranks in a deck of playing cards.

const (
	Ace Rank = iota + 1
	Two
	Three
	Four
	Five
	Six
	Seven
	Eight
	Nine
	Ten
	Jack
	Queen
	King
)

The thirteen ranks in each of the four suits.

func (Rank) String

func (r Rank) String() string

String Impelements the fmt.Stringer interface.

type Suit

type Suit int

Suit represents one of the four suit symbols in a deck of playing cards.

const (
	// Club suit ♣
	Club Suit = iota
	// Diamond suit ♦
	Diamond
	// Heart suit ♥
	Heart
	// Spade suit ♠
	Spade
)

func (Suit) String

func (s Suit) String() string

String Impelements the fmt.Stringer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL