From 8f4819ffb14f8521dcb17a7aa2e1018d04cb7fd5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 24 Mar 2018 19:22:58 -0600 Subject: [PATCH] 5.2 --- Chapter02/src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Chapter02/src/main.rs b/Chapter02/src/main.rs index d645deb..8163e4d 100644 --- a/Chapter02/src/main.rs +++ b/Chapter02/src/main.rs @@ -80,6 +80,13 @@ fn main() }; //5.2. If next floor request in queue is satisfied, then remove from queue + let next_floor = floor_request[0]; + if (location - (next_floor as f64)*floor_height).abs() && + velocity.abs() < 0.01 + { + velocity = 0.0; + floor_requests.remove(0); + } //5.3. Adjust motor control to process next floor request