Robot type

This commit is contained in:
Martin HART 2020-10-27 22:55:31 +01:00
parent 6f34f27eaa
commit f88c972ceb
2 changed files with 23 additions and 0 deletions

View File

@ -17,6 +17,8 @@ use clap::{App, Arg};
use std::fs;
use std::io;
mod robot;
/// Retrieve the content of a file and return it as a string.
fn open_file(filename: &str) -> io::Result<String> {
let content = fs::read_to_string(filename)?;

21
src/robot.rs Normal file
View File

@ -0,0 +1,21 @@
/// A Robot *aka droid* is represented here.
/// Each robot must have a unique id.
pub struct Robot {
id: u32,
o: Orientation,
p: Position,
}
/// Enum to store all possible orientations.
enum Orientation {
N,
E,
S,
W,
}
/// Struct to store robot position.
struct Position {
x: i32,
y: i32,
}