Complete quiz3

This commit is contained in:
Suzie Kim 2024-02-02 15:00:19 -05:00
parent 5e3230c931
commit 92c8633178
No known key found for this signature in database
GPG key ID: 83C4CC3808F9AAE9

View file

@ -16,15 +16,13 @@
// //
// Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint quiz3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE pub struct ReportCard<T> {
pub grade: T,
pub struct ReportCard {
pub grade: f32,
pub student_name: String, pub student_name: String,
pub student_age: u8, pub student_age: u8,
} }
impl ReportCard { impl<T: std::fmt::Display> ReportCard<T> {
pub fn print(&self) -> String { pub fn print(&self) -> String {
format!("{} ({}) - achieved a grade of {}", format!("{} ({}) - achieved a grade of {}",
&self.student_name, &self.student_age, &self.grade) &self.student_name, &self.student_age, &self.grade)
@ -52,7 +50,7 @@ mod tests {
fn generate_alphabetic_report_card() { fn generate_alphabetic_report_card() {
// TODO: Make sure to change the grade here after you finish the exercise. // TODO: Make sure to change the grade here after you finish the exercise.
let report_card = ReportCard { let report_card = ReportCard {
grade: 2.1, grade: "A+",
student_name: "Gary Plotter".to_string(), student_name: "Gary Plotter".to_string(),
student_age: 11, student_age: 11,
}; };