pub(crate) fn on_end(&mut self) -> EndState {
        if !self.board.has_player_won() && !self.board.is_every_cell_set() {
            return EndState::Continue;
        }

        if self.board.has_player_won() {
            println!("{} has won!", self.current_player);
        } else {
            println!("Draw!");
        }
        println!("Would you like to play again?");
        println!("Press Y for Yes, N for No.");

        loop {
            let mut play_again_buffer = String::new();
            std::io::stdin().read_line(&mut play_again_buffer).unwrap();
            match play_again_buffer.trim() {
                "n" | "N" => return EndState::End,
                "y" | "Y" => {
                    self.reset();
                    return EndState::Replay;
                }
                _ => {
                    println!("Please enter a valid argument.");
                    continue;
                }
            }
        }
    }
/// Handles the end state of the game.
Handles the end state of the game.
Handles the end state of the game .
pub(crate) fn on_end(&mut self) -> EndState {
        if !self.board.has_player_won() && !self.board.is_every_cell_set() {
            return EndState::Continue;
        }
        if self.board.has_player_won() {
            println!("{} has won!", self.current_player);
        } else {
            println!("Draw!");
        }
        println!("Would you like to play again?");
        println!("Press Y for Yes, N for No.");
        loop {
            let mut play_again_buffer = String::new();
            std::io::stdin().read_line(&mut play_again_buffer).unwrap();
            match play_again_buffer.trim() {
                "n" | "N" => return EndState::End,
                "y" | "Y" => {
                    self.reset();
                    return EndState::Replay;
                }
                _ => {
                    println!("Please enter a valid argument.");
                    continue;
                }
            }
        }
    }
pub ( crate ) fn on_end ( & mut self ) -> EndState { if ! self . board . has_player_won ( ) && ! self . board . is_every_cell_set ( ) { return EndState :: Continue ; } if self . board . has_player_won ( ) { println ! ( " " self current_player ) ; } else { println ! ( " " ) ; } println ! ( " " ) ; println ! ( " " ) ; loop { let mut play_again_buffer = String :: new ( ) ; std :: io :: stdin ( ) . read_line ( & mut play_again_buffer ) . unwrap ( ) ; match play_again_buffer . trim ( ) { " " | " " => return EndState :: End , " " | " " => { self . reset ( ) ; return EndState :: Replay ; } _ => { println ! ( " " ) ; continue ; } } } }
Handles the end state of the game.
Handles the end state of the game .
&mut self