Gene refactor
This commit is contained in:
parent
85faa9be22
commit
5abbbc3bf9
8 changed files with 114 additions and 106 deletions
34
rust-pvz-genetics/src/genetics/gene/mod.rs
Normal file
34
rust-pvz-genetics/src/genetics/gene/mod.rs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
pub mod gene_types;
|
||||
pub mod gene_place;
|
||||
pub mod gene_source;
|
||||
|
||||
pub use gene_types::GeneType;
|
||||
pub use gene_source::GeneSource;
|
||||
pub use gene_place::GenePlace;
|
||||
|
||||
#[derive(PartialEq,Eq,Clone)]
|
||||
pub struct Gene {
|
||||
pub plant_source: GeneSource,
|
||||
pub place: GenePlace,
|
||||
pub kind: GeneType
|
||||
}
|
||||
|
||||
impl Gene {
|
||||
pub fn new(plant_source: GeneSource, place: GenePlace, kind: GeneType) -> Self {
|
||||
Self {
|
||||
plant_source,
|
||||
place,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Display for Gene {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f,"({}) {}",self.plant_source,self.place)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue