Tell me a story I could code

mnivoliez

mnivoliez

Posted on May 6, 2018

Tell me a story I could code

Originally post on my blog

Hello everyone! Today one colleague and friend of mine, Gaetan, would like to propose you a simple (or not) concept!

It's a code of which you are the story teller!

"Whaaaaat?"

whaaaaat

Let me explain! We propose you to tell a story (a little one), sentence by sentence. Each time a sentences is selected, we will try to express the story into code.

An exemple is worth 1000 speech so here is the start of our story:

"Once upon a time, a young knight name Bob found a penny!"

#[derive(Debug)]
struct Story {
    pub time: &'static str,
    pub main_character: Character,
}

#[derive(Debug)]
struct Character {
    pub name: &'static str,
    pub money: i32,
}

fn found_a_strange_penny(character: &mut Character) {
    character.money += 1;
    println!("Oh a penny! \" said {}.\"", character.name);
}

fn main() {
    let mut story = Story {
        time: "Once upon a time",
        main_character: Character {
            name: "Bob",
            money: 0,
        },
    };

    found_a_strange_penny(&mut story.main_character);
}
Enter fullscreen mode Exit fullscreen mode

All the code will live in this repository.

So, it's up to you, reader, to continue the story.
Post a comment with one sentence or two and we will try to code that.
We will choose the comment that appeal us the most!

Start :p

--
Gaetan and Mathieu

💖 💪 🙅 🚩
mnivoliez
mnivoliez

Posted on May 6, 2018

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related