use std::{io::BufRead, fmt::Display, error::Error};
pub struct BinaryQuery<T>
where T: Display
{
pub positive_choice: T,
pub negative_choice: T,
pub answer: String,
}
impl<T> BinaryQuery<T>
where T: Display
{
pub fn new<I: BufRead>(message: &str, positive_choice: T, negative_choice: T, input_handle: &mut I) -> Result<Self, Box<dyn Error>> {
println!("{}", message);
println!("Positive answer: {}", positive_choice);
println!("Negative answer: {}", negative_choice);
let mut user_input = String::default();
input_handle.read_line(&mut user_input)?;
Ok(Self { positive_choice, negative_choice, answer: user_input.trim().to_string() })
}
}