feat: Add tooth display

This commit is contained in:
2022-08-03 15:57:29 +02:00
parent 970b7f6f64
commit 962c9db6f9
5 changed files with 96 additions and 4 deletions

View File

@@ -13,6 +13,13 @@ pub enum QuadrantKind {
BottomRight,
}
pub enum ToothType {
Incisor,
Canine,
Premolar,
Molar,
}
pub struct Tooth {
quadrant: QuadrantKind,
number: u8,
@@ -20,7 +27,7 @@ pub struct Tooth {
}
impl Tooth {
fn _new(number: u8, quadrant: QuadrantKind, permanent: bool) -> Result<Tooth, String> {
pub fn new(number: u8, quadrant: QuadrantKind, permanent: bool) -> Result<Tooth, String> {
if let Err(err) = Tooth::check_tooth_number(number, permanent) {
return Err(err);
}
@@ -48,7 +55,7 @@ impl Tooth {
}
}
fn quadrant_max(permanent: bool) -> u8 {
pub fn quadrant_max(permanent: bool) -> u8 {
if permanent {
8
} else {
@@ -155,7 +162,7 @@ impl Tooth {
};
if self.permanent {
value.to_string()
format!("{:2}", value)
} else {
((value + 64) as char).to_string()
}
@@ -254,6 +261,15 @@ impl Tooth {
Err(err) => Err(err),
}
}
pub fn get_type(&self) -> ToothType {
match (&self.number, &self.permanent) {
(1..=2, _) => ToothType::Incisor,
(3, _) => ToothType::Canine,
(4..=5, true) => ToothType::Premolar,
_ => ToothType::Molar,
}
}
}
#[cfg(test)]