Skip to contents

Constructs a custom S3 rcrd object of class "card", with validated rank and suit fields. Used as the foundation for representing cards in the Blackjack game package.

Usage

card(rank = character(), suit = character())

Arguments

rank

A character vector of ranks (e.g., "A", "2", ..., "K").

suit

A character vector of suits (e.g., "♠", "♥", "♦", "♣").

Value

An object of class "card" representing the provided cards.

Details

This constructor performs input validation to ensure ranks and suits are valid and of equal length. Use this function to create cards manually or when writing helper functions that build decks or hands.

Examples

card(c("A", "10", "Q"), c("♠", "♥", "♦"))
#> <card[3]>
#> [1] A♠  10♥ Q♦