Created
December 10, 2023 07:23
-
-
Save isaacssemugenyi/69311b0b76a25fa40249bdeb8439cff3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn check_user_meter_number() { | |
let mut customer_option: String = String::new(); | |
println!("Are you a new customer or an existing customer: "); | |
println!("1. Yes"); | |
println!("2. No"); | |
stdin() | |
.read_line(&mut customer_option) | |
.expect("Not a valid selection"); | |
match customer_option.trim().parse::<u8>() { | |
Ok(option) => { | |
match option { | |
1 => { | |
// prompt user to input meter number | |
let mut folder_name: String = String::new(); | |
println!("Great! Please enter your meter number: "); | |
stdin() | |
.read_line(&mut folder_name) | |
.expect("Not a valid selection"); | |
let result = check_directory_exists(folder_name.trim()); | |
match result { | |
Ok(_) => { | |
match result { | |
Ok(_) => { | |
get_print_main_menu(folder_name.trim()); | |
// concatenate the meter number with the generated receipt number | |
// save | |
} | |
Err(e) => println!("{}", e), | |
} | |
}, | |
Err(_) => print!("Meter number {} not found", folder_name), | |
} | |
} | |
2 => { | |
let mut choosen_option: String = String::new(); | |
println!("Do you want to become a customer: "); | |
println!("1. Yes"); | |
println!("2. No"); | |
stdin() | |
.read_line(&mut choosen_option) | |
.expect("Not a valid selection"); | |
match choosen_option.trim().parse::<u8>() { | |
Ok(current_option) => match current_option { | |
1 => { | |
let (_, generated_meter_number) = generate_random_receipt_numbers(); | |
create_user_meter_number(generated_meter_number.to_string().trim()); | |
} | |
2 => println!("Thank you for using visiting us and enjoy your day"), | |
_ => println!("The option select is not a valid selection") | |
}, | |
Err(e) => println!("Invalid input {}", e), | |
} | |
} | |
_ => println!("Unknown option selected"), | |
} | |
} | |
Err(e) => { | |
println!("An error occured with provided receipt number, {}", e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment