Begin implementation of commit.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-08-19 12:43:56 +02:00
parent e98a5dd002
commit b6d61b5ee9
2 changed files with 13 additions and 3 deletions

View File

@ -29,6 +29,8 @@ pub struct Habit
priority:char, priority:char,
// Day 0 is Monday. Use number_days_from_monday() to determine index. // Day 0 is Monday. Use number_days_from_monday() to determine index.
days_active:[bool;7], days_active:[bool;7],
done:bool,
streak:i32,
} }
impl Habit impl Habit
@ -46,6 +48,8 @@ impl Habit
bad, bad,
priority, priority,
days_active, days_active,
done: false,
streak: 0,
} }
} }
@ -85,9 +89,13 @@ impl Habit
pub fn get_name(&self) -> &String { &self.name } pub fn get_name(&self) -> &String { &self.name }
pub fn get_bad(&self) -> bool { self.bad } pub fn get_bad(&self) -> bool { self.bad }
pub fn get_priority(&self) -> char { self.priority } pub fn get_priority(&self) -> char { self.priority }
pub fn get_done(&self) -> bool { self.done }
pub fn get_streak(&self) -> i32 { self.streak }
pub fn set_name(&mut self, name:String) { self.name = name; } pub fn set_name(&mut self, name:String) { self.name = name; }
pub fn set_bad(&mut self, bad:bool) { self.bad = bad; } pub fn set_bad(&mut self, bad:bool) { self.bad = bad; }
pub fn set_priority(&mut self, priority:char) { self.priority = priority; } pub fn set_priority(&mut self, priority:char) { self.priority = priority; }
pub fn set_days(&mut self, days:[bool;7]) { self.days_active = days; } pub fn set_days(&mut self, days:[bool;7]) { self.days_active = days; }
pub fn set_done(&mut self, done:bool) { self.done = done; }
// TODO: whether set_streak or inc/dec/reset_streak
} }

View File

@ -192,16 +192,18 @@ impl HabitMgr
} }
else else
{ {
println!(" {0: <3} | {1: <5} | {2: <8} | {3}", println!(" {0: <3} | {1: <5} | {2: <8} | {3: <5} | {4: <6} | {5}",
"id", "bad", "priority", "name"); "id", "bad", "priority", "done", "streak", "name");
for (i, habit) in self.habits.iter().enumerate() for (i, habit) in self.habits.iter().enumerate()
{ {
if all || habit.active_today() if all || habit.active_today()
{ {
println!(" {0: <3} | {1: <5} | {2: <8} | {3}", println!(" {0: <3} | {1: <5} | {2: <8} | {3: <5} | {4: <6} | {5}",
i, i,
habit.get_bad(), habit.get_bad(),
habit.get_priority(), habit.get_priority(),
habit.get_done(),
habit.get_streak(),
habit.get_name()); habit.get_name());
} }
} }