예제 #1
0
        static Habit CreateHabit()
        {
            Console.WriteLine("\n Enter habit title");
            string name      = Console.ReadLine();
            string dificulty = "";

            while (dificulty != "1" && dificulty != "2" && dificulty != "3")
            {
                Console.WriteLine("Enter habit dificulty 1 (low), 2 (medium) or 3 (hard)");
                dificulty = Console.ReadLine();
            }
            string type = "";

            while (type != "1" && type != "2")
            {
                Console.WriteLine("Enter habit type 1 (good) or 2 (bad)");
                type = Console.ReadLine();
            }
            int group = -1;

            while (group < 1 || group > 6)
            {
                Console.WriteLine("Enter habit group ");
                Console.WriteLine("1 (ExerciseAndSport) ");
                Console.WriteLine("2 (StudyAndLearning) ");
                Console.WriteLine("3 (ActivitieasAndHobbies) ");
                Console.WriteLine("4 (WorkAndCareer) ");
                Console.WriteLine("5 (HomeAndPersonal) ");
                Console.WriteLine("6 (Other) ");
                group = int.Parse(Console.ReadLine());
            }
            DateTime date = new DateTime(1900, 1, 1);

            Console.WriteLine("Enter habit Date");
            bool parsedDate = DateTime.TryParse(Console.ReadLine(), out DateTime dateParsedSuccess);

            if (parsedDate)
            {
                date = dateParsedSuccess;
            }
            else
            {
                Console.WriteLine("Please enter valid data format, Ex: 2020/03/24");
                Console.WriteLine("Press 'ENTER' and try again ...");
                Console.ReadLine();
                CreateHabit();
            }

            int dificultyInt = int.Parse(dificulty);
            int typeInt      = int.Parse(type);

            Habit temp = new Habit(name, (EnumHabitGroup)group, (EnumHabitDificulty)dificultyInt, (EnumGoodBad)typeInt, date, false);

            return(temp);
        }
예제 #2
0
        public static void AddHabit(string userName, Habit habit)
        {
            var account = GetAccount(userName);

            account.Habits.Add(habit);
        }
예제 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Do you want to login (1) or create an account (2) ?");
            var input  = Console.ReadLine();
            int answer = CheckInputHelper.CheckTwoPossibilities(input);

            switch (answer)
            {
            case 1:
                //login
                var loggedUser = Login.LoginUser();
                if (loggedUser == null)
                {
                    break;
                }
                LoggedIn.LoggedIn(loggedUser);

                break;

            case 2:
                //register
                Register.RegisterNewUser();
                Console.WriteLine("Do you want to add another habit(1), log into your account(2) or exit the application(3)?");
                var input1  = Console.ReadLine();
                int answer1 = CheckInputHelper.CheckThreePossibilities(input1);

                switch (answer1)
                {
                //add another habit
                case 1:
                    Console.WriteLine("Do you want to add a good habit(1) or a bad habit(2)?");
                    var input2   = Console.ReadLine();;
                    int answer2  = CheckInputHelper.CheckTwoPossibilities(input2);
                    var lastUser = User.AllUsers[User.AllUsers.Count - 1];
                    if (answer2 == 1)
                    {
                        var goodHabit = new Habit();

                        lastUser.GoodHabits.Add(goodHabit);
                        Console.WriteLine("Please set a good habit.");
                        HabitsAdder.SetHabit(goodHabit);
                    }
                    else if (answer2 == 2)
                    {
                        var badHabit = new Habit();

                        lastUser.BadHabits.Add(badHabit);
                        Console.WriteLine("Please set a bad habit.");
                        HabitsAdder.SetHabit(badHabit);
                    }
                    break;

                //login
                case 2:
                    var loggedUser1 = Login.LoginUser();
                    if (loggedUser1 == null)
                    {
                        break;
                    }
                    LoggedIn.LoggedIn(loggedUser1);
                    break;

                //exit application
                case 3:
                    break;
                }

                break;
            }
        }
예제 #4
0
 public HabitResult(Habit habit)
 {
     this._habit = habit;
 }
예제 #5
0
 public Fail(Habit habit) : base(habit)
 {
 }
예제 #6
0
 public Success(Habit habit) : base(habit)
 {
 }
예제 #7
0
        static void Main(string[] args)
        //Main is an entry point, everybody has Main and don't delete
        {
            Console.WriteLine("***Welcome to your HabitTracker!***");

            while (true)
            {
                Console.WriteLine("0. Exit");
                Console.WriteLine("1. Create an account");
                Console.WriteLine("2. Create a habit");
                Console.WriteLine("3. Track a habit");
                Console.WriteLine("4. Print all habits");

                var    option = Console.ReadLine();
                string userName;
                string habitName;
                switch (option)
                {
                case "0":
                    Console.WriteLine("Thank you for visiting your Habit Tracker!");
                    return;

                case "1":
                    Console.WriteLine("Username: "******"2":
                    Console.WriteLine("Username: "******"Habit Name: ");
                    habitName = Console.ReadLine();
                    Console.WriteLine("Habit Weekly Goal: ");
                    var weeklyGoalString = Console.ReadLine();
                    var weeklyGoal       = int.Parse(weeklyGoalString);
                    var habit            = new Habit
                    {
                        Name       = habitName,
                        WeeklyGoal = weeklyGoal
                    };
                    AccountStore.AddHabit(userName, habit);
                    break;

                case "3":
                    Console.WriteLine("Username: "******"Habit Name: ");
                    habitName = Console.ReadLine();
                    AccountStore.TrackHabit(userName, habitName);
                    break;

                case "4":
                    Console.WriteLine("Username: "******"That is not a valid option");
                    break;
                }
            }
        }