diff --git a/engine/src/lib.rs b/engine/src/lib.rs index 0fbbdef..6fa013c 100644 --- a/engine/src/lib.rs +++ b/engine/src/lib.rs @@ -61,14 +61,22 @@ impl Board { } } +static COLUMN_COORDINATE_BORDER: &str = " ABCDEFGHIJKL"; + impl fmt::Display for Board { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - // TODO: Add a A-Z and 1-12 border around the game. let width = self.dimensions.get_size(); - let height= self.dimensions.get_size(); - // TODO: Implement a looping setup for the checkerboard. + // Create the top level border. + let mut column_border_chars = COLUMN_COORDINATE_BORDER.chars(); + for _ in 0..width + 1 { + write!(formatter, "{}", column_border_chars.next().unwrap())?; + } + write!(formatter, "\n")?; + + + // for {} // // let square = match tile { @@ -85,8 +93,14 @@ impl fmt::Display for Board { #[cfg(test)] mod tests { + use crate::Board; + use crate::BoardSize; + #[test] - fn it_works() { - assert_eq!(2 + 2, 4); + fn setup_international_board() { + + let expected = r#" ABCDEFGHIJ +"#; + assert_eq!(Board::new(BoardSize::International).to_string(), expected); } }