From 8fa3fa881bc3b954e136295fe6cc7022737ae9db Mon Sep 17 00:00:00 2001 From: Guillaume Pasquet Date: Tue, 12 Nov 2019 14:22:19 +0100 Subject: Refactor all the things! --- src/computer.rs | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 src/computer.rs (limited to 'src/computer.rs') diff --git a/src/computer.rs b/src/computer.rs deleted file mode 100644 index a8b9b3e..0000000 --- a/src/computer.rs +++ /dev/null @@ -1,36 +0,0 @@ -pub struct Computer { - level: i32, - difficulty: i32, -} - -pub trait Enemy { - fn new(level: i32, difficulty: i32) -> Self; - - fn action(&self) -> (i32, i32); - - fn level_up(&mut self); - - fn stats(&self) -> String; -} - -impl Enemy for Computer { - fn new(level: i32, difficulty: i32) -> Computer { - Computer { - level: level, - difficulty: difficulty - } - } - - fn action(&self) -> (i32, i32) { - (self.level, self.difficulty) - } - - fn level_up(&mut self) { - self.level += 1; - self.difficulty += 3; - } - - fn stats(&self) -> String { - format!("level: {} difficulty: {}", self.level, self.difficulty) - } -} -- cgit v1.2.3