Merge pull request #4 from the-codetrane/mcain/if-and-quiz

Ifs and Quiz
This commit is contained in:
Michael Cain 2023-03-02 10:24:19 -06:00 committed by GitHub
commit 205c66c13b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 11 deletions

View File

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

View File

@ -4,13 +4,11 @@
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing! // Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
pub fn foo_if_fizz(fizzish: &str) -> &str { pub fn foo_if_fizz(fizzish: &str) -> &str {
if fizzish == "fizz" { match fizzish {
"foo" "fizz" => "foo",
} else { "fuzz" => "bar",
1 _ => "baz",
} }
} }

View File

@ -10,10 +10,14 @@
// Write a function that calculates the price of an order of apples given // Write a function that calculates the price of an order of apples given
// the quantity bought. No hints this time! // the quantity bought. No hints this time!
// I AM NOT DONE
// Put your function here! // Put your function here!
// fn calculate_price_of_apples { fn calculate_price_of_apples(amount: u32) -> u32 {
if amount > 40 {
return amount * 1;
} else {
return amount * 2;
}
}
// Don't modify this function! // Don't modify this function!
#[test] #[test]