add tests

This commit is contained in:
2022-05-03 15:45:37 +02:00
parent d8e2107cce
commit 1d49b31272
4 changed files with 355 additions and 148 deletions
+25 -20
View File
@@ -1,26 +1,27 @@
mod human;
mod disease;
mod human;
mod population;
mod prelude {
pub use crate::human::*;
pub use crate::disease::*;
pub use crate::human::*;
pub use crate::population::*;
pub use rand::Rng;
pub use console::Term;
pub use console::style;
pub const CORRECTED_PERCENTAGE:i32 = 101;
pub use console::Term;
pub use rand::Rng;
pub const CORRECTED_PERCENTAGE: i32 = 101;
}
use prelude::*;
fn main() {
let term = Term::stdout();
term.write_line("********** Rusty Propagation (Console) 2022 **********").expect("Oops Looks like we have a problem here...");
term.write_line("Press any key to start the propagation").expect("Oops Looks like we have a problem here...");
term.write_line("********** Rusty Propagation (Console) 2022 **********")
.expect("Oops Looks like we have a problem here...");
term.write_line("Press any key to start the propagation")
.expect("Oops Looks like we have a problem here...");
let disease = Disease::new(20,10,5,String::from("Covid 44"));
let mut population = Population::new(20,10,5,300,300,disease);
let disease = Disease::new(20, 10, 5, String::from("Covid 44"));
let mut population = Population::new(20, 10, 5, 300, 300, disease);
//population.change_disease(disease);
println!("Before Filling");
//population.display();
@@ -28,17 +29,21 @@ fn main() {
println!("After Filling");
//population.display();
println!("After Propagation");
let mut stats: [i32;4];
// = [0,0,0,0];
let mut counter:u32 = 0;
loop{
let mut stats: [i32; 4];
// = [0,0,0,0];
let mut counter: u32 = 0;
loop {
counter += 1;
stats=population.propagate();
stats = population.propagate();
//population.display();
println!("Infecteds: {} Immunes: {} Deads: {}",stats[1],stats[2],stats[3]);
if stats[1] == 0 {break;}
}
println!("Propagation finished in {} steps",counter);
println!(
"Infecteds: {} Immunes: {} Deads: {}",
stats[1], stats[2], stats[3]
);
if stats[1] == 0 {
break;
}
}
println!("Propagation finished in {} steps", counter);
//population.display();
}