diff options
| -rw-r--r-- | src/main.rs | 6 | ||||
| -rw-r--r-- | src/pomo.rs | 27 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index e7a11a9..324d34e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +mod pomo; +use pomo::Pomo; + fn main() { - println!("Hello, world!"); + let mut app = Pomo::new(); + app.run(); } diff --git a/src/pomo.rs b/src/pomo.rs new file mode 100644 index 0000000..a5042ef --- /dev/null +++ b/src/pomo.rs @@ -0,0 +1,27 @@ +use std::{ thread, time::Duration }; + +pub struct Pomo { + pub time_remaining: Duration, +} + +impl Pomo { + pub fn new() -> Self { + Self { + time_remaining: Duration::from_secs(25 * 60), + } + } + + pub fn tick(&mut self) { + self.time_remaining -= Duration::from_secs(1); + } + + pub fn run(&mut self) { + self.time_remaining = Duration::from_secs(10); + while self.time_remaining > Duration::from_secs(0) { + println!("{}", self.time_remaining.as_secs()); + self.tick(); + thread::sleep(Duration::from_secs(1)); + } + println!("Done"); + } +} |