Added Card Struct #10

Merged
wesley merged 1 commits from feature/card into development 2026-01-10 15:37:00 -05:00
2 changed files with 37 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
use std::fmt;
pub struct Card {
pub suit: u8,
pub value: u8,
}
impl fmt::Display for Card {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let value = match self.value {
0 => "A",
1 => "2",
2 => "3",
3 => "4",
4 => "5",
5 => "6",
6 => "7",
7 => "8",
8 => "9",
9 => "10",
10 => "J",
11 => "Q",
12 => "K",
_ => "",
};
let suit = match self.suit {
0 => "H",
1 => "C",
2 => "D",
3 => "S",
_ => "",
};
write!(f, "{}{}", value, suit)
}
}

View File

@@ -1,9 +1,9 @@
use std::error::Error; use std::error::Error;
mod card; mod card;
mod hand;
mod deck; mod deck;
mod gamestate; mod gamestate;
mod hand;
pub fn run() -> Result<(), Box<dyn Error>> { pub fn run() -> Result<(), Box<dyn Error>> {
println!("Hello, world!"); println!("Hello, world!");