Exemplo n.º 1
0
        public void showBoard()
        {
            Console.WriteLine("Do you wanna show your Habits (H), Dailies (D), To-Do (T) or your stats (S)? Close program (E)?");
            string choice = Console.ReadLine();

            switch (choice)
            {
            case "H":
                habitsList(); break;

            case "D":
                break;

            case "T":
                break;

            case "S":
                user.myStats();
                break;

            case "E":
                saveNewState();
                Environment.Exit(1);
                break;

            default:
                Console.WriteLine("Error."); break;
            }
            showBoard();
        }
Exemplo n.º 2
0
        public void addUser()
        {
            User user = new User("");

            Console.WriteLine("Write your name (use whtever you wants, but not \"@\"): ");
            string name       = Console.ReadLine();
            bool   userExists = false;

            if (name.Contains('@'))
            {
                Console.WriteLine("I wrote, don't use \"@\" :( One more time?");
                addUser();
            }
            else
            {
                foreach (User u in users)
                {
                    if (u.name == name)
                    {
                        userExists = true;
                    }
                }
                if (userExists == false)
                {
                    user = new User(name);
                    StreamWriter swHabits  = new StreamWriter(user.name + "_Habits.txt");
                    StreamWriter swToDo    = new StreamWriter(user.name + "_ToDos.txt");
                    StreamWriter swDailies = new StreamWriter(user.name + "_Dailies.txt");
                    StreamWriter swUser    = new StreamWriter("Users.txt");
                    swUser.WriteLine(user.name + "@" + user.exp + "@" + user.lvl + "@" + user.health);

                    swUser.Close();
                    swDailies.Close();
                    swToDo.Close();
                    swHabits.Close();
                    Console.WriteLine("Created. Your stats: ");
                    user.myStats();
                    users.Add(user);
                }
                else
                {
                    Console.WriteLine("User exists! Look at the list of users.");
                }
            }
        }