From a4444a9fb11857e76f17bd09e4232c5efb56f01e Mon Sep 17 00:00:00 2001 From: leca Date: Wed, 27 Mar 2024 14:06:48 +0300 Subject: [PATCH] added percentage --- src/ui/guessing/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/guessing/mod.rs b/src/ui/guessing/mod.rs index 4d28d1c..6e0e805 100644 --- a/src/ui/guessing/mod.rs +++ b/src/ui/guessing/mod.rs @@ -117,7 +117,7 @@ pub fn build_game(_w: &RefCell) -> Box { let answer: &String = &entry.text().to_string(); println!("{} <-> {}? = {}", answer, correct_answer.borrow().to_string(), *answer == correct_answer.borrow().to_string()); *stats.borrow_mut() = if *answer == correct_answer.borrow().to_string() { (stats.borrow().0 + 1, stats.borrow().1) } else {(stats.borrow().0, stats.borrow().1 + 1)}; - counter_label.borrow_mut().set_label(format!("Correct|Incorrect: {}|{}", stats.borrow().0, stats.borrow().1).as_str()); + counter_label.borrow_mut().set_label(format!("Correct|Incorrect: {}|{} ({:.2}%)", stats.borrow().0, stats.borrow().1, 100.0 * f64::from(stats.borrow().0) / f64::from(stats.borrow().0 + stats.borrow().1)).as_str()); *question.borrow_mut() = ask(ktr, rtk, hiragana, katakana); *exact_kana.borrow_mut() = if hiragana && katakana {