Exemple #1
0
        static void Main(string[] args)
        {
            Notebook notebook = new Notebook();

            notebook.AddNote(new Note("Note1", "Text1"));
            notebook.AddNote(new Note("Note2", "Text2"));
            notebook.AddNote(new Note("Note3", "Text3"));
            IAbstractIterator iterator = notebook.GetIterator();

            for (Note note = iterator.First(); !iterator.IsDone; note = iterator.Next())
            {
                note.Show();
            }

            Box box = new Box();

            box.AddProduct(new Product("Product1", 10.99));
            box.AddProduct(new Product("Product2", 5));
            box.AddProduct(new Product("Product3", 12.8));
            IAbstractIteratorBox iteratorbox = box.GetIterator();

            for (Product product = iteratorbox.First(); !iteratorbox.IsDone; product = iteratorbox.Next())
            {
                Console.WriteLine(product.ToString());
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Product product1 = new Product("Keyboard", 22.20);
            Product product2 = new Product("USB", 17.50);
            Product product3 = new Product("Mouse", 35.25);

            Box box = new Box();

            box.AddProduct(product1);
            box.AddProduct(product2);
            box.AddProduct(product3);
            box.RemoveProduct(product3);

            IAbstractIterator boxIterator = box.GetIterator();

            while (!boxIterator.IsDone)
            {
                Console.WriteLine(boxIterator.Current);
                boxIterator.Next();
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Notebook notebook  = new Notebook();
            Note     noteOne   = new Note("Danas je četvrtak.", "Vikend se bliži!");
            Note     noteTwo   = new Note("Dobro jutro!", "Laku noć!");
            Note     noteThree = new Note("Valar Morghulis", "Valar Dohaeris");

            notebook.AddNote(noteOne);
            notebook.AddNote(noteTwo);
            notebook.AddNote(noteThree);

            Iterator iterator = new Iterator(notebook);

            for (int i = 0; i < notebook.Count; i++)
            {
                iterator.Current.Show();
                iterator.Next();
            }

            Box     box          = new Box();
            Product productOne   = new Product("Šišanje", 80);
            Product productTwo   = new Product("Frizura", 120);
            Product productThree = new Product("Pranje kose", 20);

            box.AddProduct(productOne);
            box.AddProduct(productTwo);
            box.AddProduct(productThree);

            BoxIterator boxIterator = new BoxIterator(box);

            for (int i = 0; i < box.Count; i++)
            {
                boxIterator.Current.Show();
                boxIterator.Next();
            }

            BankAccountCareTaker bankAccountCareTaker = new BankAccountCareTaker();
            BankAccount          bankAccount          = new BankAccount("Ana", "Virovitica", 1000);
            BankAccountMemento   memento = new BankAccountMemento(bankAccount);

            bankAccountCareTaker.PreviousState = memento;
            Console.WriteLine(bankAccountCareTaker.PreviousState.Balance.ToString() + "HRK");
            bankAccount.UpdateBalance(250);
            memento.AddPreviousState(bankAccount);
            bankAccountCareTaker.PreviousState = memento;
            Console.WriteLine(bankAccountCareTaker.PreviousState.Balance.ToString() + "HRK" + "\n");

            AbstractLogger logger     = new ConsoleLogger(MessageType.ALL);
            FileLogger     fileLogger = new FileLogger(MessageType.ERROR | MessageType.WARNING, "logFile.txt");

            logger.Log("Covid-19", MessageType.INFO);
            fileLogger.Log("Dezinfekcija", MessageType.WARNING);
            fileLogger.Log("Virus", MessageType.ERROR);

            string        s                = "53h&eds";
            StringChecker digitChecker     = new StringDigitChecker();
            StringChecker upperCaseChecker = new StringUpperCaseChecker();
            StringChecker lowerCaseChecker = new StringLowerCaseChecker();

            Console.WriteLine("Contains digit: " + digitChecker.Check(s));
            Console.WriteLine("Contains upper letter: " + upperCaseChecker.Check(s));
            Console.WriteLine("Contains lower letter: " + lowerCaseChecker.Check(s));
        }