Hello,
I have to implmement a clock and so far I have this :
pub struct Clock{
hour: i32,
minutes: i32,
}
impl Clock {
pub fn new(hours: i32, minutes: i32) -> Self {
Clock {
hour:
)
}
pub fn add_minutes(&self, minutes: i32) -> Self {
unimplemented!("Add {} minutes to existing Clock time", minutes);
}
}
how can I take care that the hours and the minutes are never above the 24 or 59
I know there are test that have invalid numbers where I have to make them valid
#[test]
#[ignore]
fn test_hour_rolls_over() {
assert_eq!(Clock::new(25, 0).to_string(), "01:00");
}
#[test]
#[ignore]
fn test_hour_rolls_over_continuously() {
assert_eq!(Clock::new(100, 0).to_string(), "04:00");
}
#[test]
#[ignore]
fn test_sixty_minutes_is_next_hour() {
assert_eq!(Clock::new(1, 60).to_string(), "02:00");