From f13fc1b30386b5e3a6b6f0b6764e049d4b4b4ed0 Mon Sep 17 00:00:00 2001 From: Pedro Morais Date: Tue, 20 Feb 2024 14:44:02 +0000 Subject: [PATCH] quiz 3 --- exercises/quiz3.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exercises/quiz3.rs b/exercises/quiz3.rs index 3b01d31..6af705b 100644 --- a/exercises/quiz3.rs +++ b/exercises/quiz3.rs @@ -16,15 +16,16 @@ // // Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE -pub struct ReportCard { - pub grade: f32, +use std::fmt::Display; + +pub struct ReportCard { + pub grade: T, pub student_name: String, pub student_age: u8, } -impl ReportCard { +impl ReportCard { pub fn print(&self) -> String { format!("{} ({}) - achieved a grade of {}", &self.student_name, &self.student_age, &self.grade) @@ -34,7 +35,7 @@ impl ReportCard { #[cfg(test)] mod tests { use super::*; - + #[test] fn generate_numeric_report_card() { let report_card = ReportCard { @@ -52,7 +53,7 @@ mod tests { fn generate_alphabetic_report_card() { // TODO: Make sure to change the grade here after you finish the exercise. let report_card = ReportCard { - grade: 2.1, + grade: "A+", student_name: "Gary Plotter".to_string(), student_age: 11, };