This project provides a simple demonstration of a deck of playing cards using Go (Golang). You can perform various operations such as creating a new deck, shuffling the deck, saving the deck to a file, and loading the deck from a file.
- deck.go - Contains the main logic for the deck type and its associated functions/methods. This includes functionalities such as creating a new deck, printing a deck, dealing, shuffling, and saving/loading a deck from a file.
- main.go - The entry point of the program. It uses the functionalities from deck.go to demonstrate their usage.
- deck_test.go - Contains unit tests to ensure the functionalities in deck.go work as expected.
- newDeck(): Returns a new deck of cards.
- print(): Prints the deck of cards.
- deal(deck, handSize): Deals a hand of cards.
- toString(): Converts the deck to a comma-separated string.
- saveToFile(filename): Saves the deck to a file.
- newDeckFromFile(filename): Loads the deck from a file.
- shuffle(): Shuffles the deck of cards.
To run the main program:
go run main.go deck.go
To run the unit tests:
go test