use crate::gmns::types::ZoneID;
#[derive(Debug, Clone)]
pub struct Zone {
pub id: ZoneID,
pub name: String,
pub population: f64,
pub employment: f64,
pub area_sq_km: f64,
pub avg_income: f64,
pub households: f64,
}
impl Zone {
pub fn new(id: ZoneID) -> ZoneBuilder {
ZoneBuilder {
instance: Zone {
id,
name: String::new(),
population: 0.0,
employment: 0.0,
area_sq_km: 0.0,
avg_income: 0.0,
households: 0.0,
},
}
}
}
pub struct ZoneBuilder {
instance: Zone,
}
impl ZoneBuilder {
pub fn with_name(mut self, name: impl Into<String>) -> Self {
self.instance.name = name.into();
self
}
pub fn with_population(mut self, population: f64) -> Self {
self.instance.population = population;
self
}
pub fn with_employment(mut self, employment: f64) -> Self {
self.instance.employment = employment;
self
}
pub fn with_area_sq_km(mut self, area: f64) -> Self {
self.instance.area_sq_km = area;
self
}
pub fn with_avg_income(mut self, income: f64) -> Self {
self.instance.avg_income = income;
self
}
pub fn with_households(mut self, households: f64) -> Self {
self.instance.households = households;
self
}
pub fn build(self) -> Zone {
self.instance
}
}