chore: St registry assignment#14
chore: St registry assignment#14RichoKD wants to merge 4 commits intoBlockheaderWeb3-Community:st-registry-assignmentfrom
Conversation
Abeeujah
left a comment
There was a problem hiding this comment.
Great Job, The CLI state machine is a great way to demonstrate your rust skills, consider implementing the prescribed changes.
src/student_registry_project/ex_1.rs
Outdated
| // } | ||
| fn get_courses(rust_cohort: &mut StudentRegistry) -> u32 { | ||
| print!("{:#?}", rust_cohort.course_registry); | ||
| io::stdout().flush().unwrap(); |
There was a problem hiding this comment.
Prefer to use println! macro, if newline behavior is the default.
src/student_registry_project/ex_1.rs
Outdated
|
|
||
| print!("1. Add student\n2. Get student\n3.Enroll student in course\n4.Return\n"); | ||
| io::stdout().flush().unwrap(); | ||
|
|
There was a problem hiding this comment.
Consider implementing utility functions to parse user inputs. This will help keep the code modular and DRY.
src/student_registry_project/ex_1.rs
Outdated
| .expect("Failed to read line"); | ||
| let sex = sex.trim().parse::<u8>().unwrap(); | ||
|
|
||
| if sex == 1 { |
There was a problem hiding this comment.
let sex = if sex == 1 { Sex::Male } else {Sex::Female };
Initialise the student.
src/student_registry_project/ex_1.rs
Outdated
| let mut id = String::new(); | ||
| io::stdin().read_line(&mut id).expect("Failed to read line"); | ||
| let id = id.trim().parse::<u32>().unwrap(); | ||
| let student = rust_cohort.get_student_by_id(id); |
There was a problem hiding this comment.
In critical mission applications, Consider handling cases where value could be Some or None. This function returns an Option
| id: course_id, | ||
| name: _name, | ||
| capacity: _capacity, | ||
| enrolled_student_ids: Vec::new(), |
src/student_registry_project/ex_1.rs
Outdated
| .trim() | ||
| .parse::<i32>() | ||
| .expect("Invalid input. Please enter a number."); | ||
|
|
There was a problem hiding this comment.
Consider using a match expression.
Implemented CLI state machine for student and course management
added ex_1.rs file to student_registry_project which takes user input to alter flow state and implement course management functions