if an quiz1 exercises complete

This commit is contained in:
Emre AYDIN 2021-01-04 20:06:45 +03:00
parent 85f57e6bc7
commit ee613636df
3 changed files with 15 additions and 7 deletions

View file

@ -1,13 +1,16 @@
// if1.rs
// I AM NOT DONE
pub fn bigger(a: i32, b: i32) -> i32 {
// Complete this function to return the bigger number!
// Do not use:
// - another function call
// - additional variables
// Execute `rustlings hint if1` for hints
if a > b {
a
} else {
b
}
}
// Don't mind this for now :)

View file

@ -4,13 +4,13 @@
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
// Execute the command `rustlings hint if2` if you want a hint :)
// I AM NOT DONE
pub fn fizz_if_foo(fizzish: &str) -> &str {
if fizzish == "fizz" {
"foo"
} else if fizzish == "fuzz" {
"bar"
} else {
1
"baz"
}
}

View file

@ -7,10 +7,15 @@
// more than 40 at once, each apple only costs 1! Write a function that calculates
// the price of an order of apples given the order amount. No hints this time!
// I AM NOT DONE
// Put your function here!
// fn ..... {
fn calculate_apple_price(num: i32) -> i32 {
if num > 40 {
num
} else {
num * 2
}
}
// Don't modify this function!
#[test]