Merge branch 'fix-name' into 'master'

Change .create_map() to .create(), and turn* to set*

See merge request mhart/DancingDroids!25
This commit is contained in:
Martin HART 2020-10-20 21:56:42 +02:00
commit dad43a7e77
1 changed files with 9 additions and 9 deletions

View File

@ -12,7 +12,7 @@ struct World {
impl World { impl World {
/// Create a new map full of dots. /// Create a new map full of dots.
fn create_map(&mut self) { fn create(&mut self) {
self.map = vec!['.'; (self.x * self.y) as usize]; self.map = vec!['.'; (self.x * self.y) as usize];
} }
/// Set robot on the map. /// Set robot on the map.
@ -74,19 +74,19 @@ impl Robot {
} }
} }
/// Apply North orientation to the robot. /// Apply North orientation to the robot.
fn turn_north(&mut self) { fn set_north(&mut self) {
self.o = Orientation::N self.o = Orientation::N
} }
/// Apply South orientation to the robot. /// Apply South orientation to the robot.
fn turn_south(&mut self) { fn set_south(&mut self) {
self.o = Orientation::S self.o = Orientation::S
} }
/// Apply East orientation to the robot. /// Apply East orientation to the robot.
fn turn_east(&mut self) { fn set_east(&mut self) {
self.o = Orientation::E self.o = Orientation::E
} }
/// Apply West orientation to the robot. /// Apply West orientation to the robot.
fn turn_west(&mut self) { fn set_west(&mut self) {
self.o = Orientation::W self.o = Orientation::W
} }
} }
@ -183,13 +183,13 @@ mod tests {
} }
#[test] #[test]
fn test_create_map() { fn test_create() {
let mut w: World = World { let mut w: World = World {
x: 5, x: 5,
y: 5, y: 5,
map: Vec::new(), map: Vec::new(),
}; };
w.create_map(); w.create();
assert_eq!(w.map, vec!['.'; 25]); assert_eq!(w.map, vec!['.'; 25]);
} }
@ -206,7 +206,7 @@ mod tests {
y: 2, y: 2,
map: Vec::new(), map: Vec::new(),
}; };
w.create_map(); w.create();
w.set_robot(r); w.set_robot(r);
assert_eq!(w.map, vec!['↑', '.', '.', '.']); assert_eq!(w.map, vec!['↑', '.', '.', '.']);
} }
@ -218,7 +218,7 @@ mod tests {
y: 2, y: 2,
map: Vec::new(), map: Vec::new(),
}; };
w.create_map(); w.create();
assert!(w.empty_position(Position { x: 0, y: 0 })); assert!(w.empty_position(Position { x: 0, y: 0 }));
} }
} }