use std::rc::Rc;
use crate::plants::plant_trait::PlantTrait;
use crate::plants::peashooter::Peashooter;
use crate::plants::sunflower::Sunflower;
use crate::plants::wallnut::WallNut;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PlantType {
Peashooter,
Sunflower,
WallNut,
}
impl PlantType {
pub fn cost(&self) -> i32 {
match self {
PlantType::Peashooter => 100,
PlantType::Sunflower => 50,
PlantType::WallNut => 50,
}
}
}
pub struct PlantFactory;
impl PlantFactory {
pub fn create_plant(plant_type: PlantType) -> Box<dyn PlantTrait> {
match plant_type {
PlantType::Peashooter => Box::new(Peashooter::new()),
PlantType::Sunflower => Box::new(Sunflower::new()),
PlantType::WallNut => Box::new(WallNut::new()),
}
}
}