mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-27 01:27:37 +02:00
* exercises: health-statistics: weight -> height weight may be a sensitive topic for some readers; use height instead as this isn't important to the content of the course * exercises: health-statistics: add health report this lets us see a non-setter use case for &mut self it also makes the 'statistics' side of this exercise more explicit as we count doctor visits * exercises: health-statistics: normalize variable names
54 lines
1019 B
Rust
54 lines
1019 B
Rust
pub struct User {
|
|
name: String,
|
|
age: u32,
|
|
height: f32,
|
|
visit_count: usize,
|
|
last_blood_pressure: Option<(u32, u32)>,
|
|
}
|
|
|
|
pub struct Measurements {
|
|
height: f32,
|
|
blood_pressure: (u32, u32),
|
|
}
|
|
|
|
pub struct HealthReport<'a> {
|
|
patient_name: &'a str,
|
|
visit_count: u32,
|
|
height_change: f32,
|
|
blood_pressure_change: Option<(i32, i32)>,
|
|
}
|
|
|
|
impl User {
|
|
pub fn new(name: String, age: u32, height: f32) -> Self {
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn name(&self) -> &str {
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn age(&self) -> u32 {
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn height(&self) -> f32 {
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn doctor_visits(&self) -> u32 {
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn set_age(&mut self, new_age: u32) {
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn set_height(&mut self, new_height: f32) {
|
|
unimplemented!()
|
|
}
|
|
|
|
pub fn visit_doctor(&mut self, measurements: Measurements) -> HealthReport {
|
|
unimplemented!()
|
|
}
|
|
}
|