Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            FileLogger logger = new FileLogger("log.txt");

            UserManager userManager = new UserManager(logger);

            User olya   = userManager.AddNewUser("Оля", "Бардецкая");
            User ruslan = userManager.AddNewUser("Руслан", "Соболь");
            User ivan   = userManager.AddNewUser("Иван", "Черкас");

            Console.WriteLine("\n****************************\n");

            DeskManager deskManager = new DeskManager(logger);

            Desk desk1 = deskManager.AddNewDesk("ДЗ№1", new DateTime(2020, 03, 15));
            Desk desk2 = deskManager.AddNewDesk("ДЗ№2", new DateTime(2020, 05, 25));

            Console.WriteLine("\n****************************\n");

            Card card1 = desk1.AddCard("github.com", "Выполненное ДЗ", olya);
            Card card2 = desk1.AddCard("github.com", "Выполненное ДЗ с некоторыми вопросами", ruslan);
            Card card3 = desk2.AddCard("github.com", "Выполненное ДЗ+ дополнительные", ivan);

            Console.WriteLine();

            Console.WriteLine("\n****************************\n");

            card1.Status = StatusTypes.OnStudent;

            Console.WriteLine("\n****************************\n");

            card1.EditCardUser(ruslan);

            Console.WriteLine("\n****************************\n");

            Console.WriteLine($"Все карточки статуса: {StatusTypes.OnStudent} ");
            PrintCards(desk1.GetCardsWithStatus(StatusTypes.OnStudent));
            Console.WriteLine($"Все карточки студента {ruslan} : ");
            PrintCards(desk2.GetUserCards(ruslan));
            Console.WriteLine("\n****************************\n");

            Console.WriteLine("\n****************************\n");

            deskManager.ShowAllDesks();

            if (card1.IsCardInTime())
            {
                Console.WriteLine($"Карточка  {card1} выполнена вовремя");
            }
            else
            {
                Console.WriteLine($"Карточка  {card1} просрочена");
            }

            Console.WriteLine("\n****************************\n");

            desk1.ShowBadStudents();
            desk2.ShowBadStudents();

            Console.WriteLine("\n****************************\n");

            PrintAllUserCards(deskManager, userManager);

            Console.WriteLine("\n**************DemonstrateExceptions**************\n");

            DemonstrateExceptions(deskManager);

            Console.WriteLine("\n**************SerializeDeskManager**************\n");

            string serializedManager = SerializeDeskManager(deskManager);

            Console.WriteLine(serializedManager);

            File.WriteAllText("serializedCard.json", serializedManager);

            Console.WriteLine("\n**************DeserializeDeskManager**************\n");

            serializedManager = serializedManager.Replace("git", "p**n");
            DeskManager deserializedManager1 = DeserializeDeskManager(serializedManager);

            Console.WriteLine(deserializedManager1 != null);

            serializedManager = serializedManager.Replace("{", "(");
            DeskManager deserializedManager2 = DeserializeDeskManager(serializedManager);

            File.ReadAllText("deserializedCard.json");

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            UserManager userManager = new UserManager();

            User olya   = userManager.AddNewUser("Оля", "Бардецкая");
            User ruslan = userManager.AddNewUser("Руслан", "Соболь");
            User ivan   = userManager.AddNewUser("Иван", "Черкас");

            Console.WriteLine("\n****************************\n");

            DeskManager deskManager = new DeskManager();

            Desk desk1 = deskManager.AddNewDesk("ДЗ№1", new DateTime(2020, 03, 15));
            Desk desk2 = deskManager.AddNewDesk("ДЗ№2", new DateTime(2020, 05, 25));

            Console.WriteLine("\n****************************\n");

            Card card1 = desk1.AddNewCard("github.com", "Выполненное ДЗ", olya);
            Card card2 = desk1.AddNewCard("github.com", "Выполненное ДЗ с некоторыми вопросами", ruslan);
            Card card3 = desk2.AddNewCard("github.com", "Выполненное ДЗ+ дополнительные", ivan);

            Console.WriteLine("\n****************************\n");

            card1.EditCardStatus(StatusTypes.OnStudent);

            Console.WriteLine("\n****************************\n");

            card1.EditCardUser(ruslan);

            Console.WriteLine("\n****************************\n");

            Console.WriteLine($"Все карточки статуса: {StatusTypes.OnStudent} ");
            PrintCards(desk1.GetCardsWithStatus(StatusTypes.OnStudent));
            Console.WriteLine($"Все карточки студента {ruslan} : ");
            PrintCards(desk2.GetUserCards(ruslan));
            Console.WriteLine("\n****************************\n");

            Console.WriteLine("\n****************************\n");

            deskManager.ShowAllDesks();

            if (card1.IsCardInTime())
            {
                Console.WriteLine($"Карточка  {card1} выполнена вовремя");
            }
            else
            {
                Console.WriteLine($"Карточка  {card1} просрочена");
            }

            Console.WriteLine("\n****************************\n");

            desk1.ShowBadStudents();
            desk2.ShowBadStudents();

            Console.WriteLine("\n****************************\n");

            PrintAllUserCards(deskManager, userManager);

            Console.ReadLine();
        }