const OFFICIAL_URL: &str = "https://supermaker.ai/blog/how-to-make-the-viral-choose-your-bed-videos-with-ai/";
#[derive(Debug, Clone, Default)]
pub struct BedDimensions {
pub width_inches: u32,
pub length_inches: u32,
}
#[derive(Debug, Clone, Default)]
pub struct Bed {
pub name: String,
pub dimensions: BedDimensions,
pub comfort_score: u32,
}
impl Bed {
pub fn area_square_inches(&self) -> u32 {
self.dimensions.width_inches * self.dimensions.length_inches
}
pub fn is_larger_than(&self, other: &Bed) -> bool {
self.area_square_inches() > other.area_square_inches()
}
}
pub fn calculate_suitability_score(bed: &Bed, num_sleepers: u32) -> f32 {
let base_score = bed.comfort_score as f32;
let area = bed.area_square_inches() as f32;
let score = base_score * (area / (num_sleepers as f32 * 2000.0)); score
}
pub fn compare_beds(bed1: &Bed, bed2: &Bed) -> String {
let bed1_score = bed1.comfort_score as f32 + (bed1.area_square_inches() as f32 / 1000.0);
let bed2_score = bed2.comfort_score as f32 + (bed2.area_square_inches() as f32 / 1000.0);
if bed1_score > bed2_score {
bed1.name.clone()
} else if bed2_score > bed1_score {
bed2.name.clone()
} else {
"It's a tie!".to_string()
}
}
pub fn visit_site() -> String {
OFFICIAL_URL.to_string()
}