Exemple #1
0
        public static Habit AddLog(Habit h)
        {
            HabitResultHandler success = new SuccessHandler(new StreakSuccess());
            HabitResultHandler fail    = new FailHandler(new StreakFail());

            h.Attach(success);
            h.Attach(fail);
            h.AddLogs();
            return(h);
        }
Exemple #2
0
        public static Habit Create(String habit_name, String[] days, Guid user, IGainer logGainer)
        {
            if (!checkDays(days))
            {
                return(null);
            }
            Habit habit = Habit.NewHabit(habit_name, user, logGainer);

            foreach (String item in days)
            {
                if ((item != "Mon") && (item != "Tue") && (item != "Wed") && (item != "Thu") && (item != "Fri") && (item != "Sat") && (item != "Sun"))
                {
                    throw new Exception("Must be 3 words!");
                }
            }
            foreach (String x in days)
            {
                habit.AddDaysOff(x);
            }

            habit.AddLogs();
            return(habit);
        }