Пример #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());
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Notebook myNotebook = new Notebook();
            Note     page1      = new Note("podsjetnik", "nemoj zaboraviti postaviti link gitHuba na stranicu kolegija");
            Note     page2      = new Note("zubar", "imas zakazano kod zubara petak 20.5.2020");

            myNotebook.AddNote(page1);
            myNotebook.AddNote(page2);
            Console.WriteLine("broj stranica je: {0}", myNotebook.Count);
            myNotebook.RemoveNote(page2);
            Console.WriteLine("broj stranica je: {0}", myNotebook.Count);
            myNotebook.Clear();
            Console.WriteLine("broj stranica je: {0}", myNotebook.Count);
            Console.Read();
        }
Пример #3
0
        static void Main(string[] args)
        {
            Notebook notebook1 = new Notebook();

            notebook1.AddNote(new Note("Test 1", "First text."));
            notebook1.AddNote(new Note("Test 2", "Second text."));
            notebook1.AddNote(new Note("Test 3", "Third text."));

            Iterator iterator1 = new Iterator(notebook1);

            iterator1.Current.Show();
            iterator1.Next().Show();

            while (iterator1.IsDone != true)
            {
                iterator1.Current.Show();
                iterator1.Next();
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            Note     note1    = new Note("Cars", "BMW, OPEL, VW, Porsche");
            Note     note2    = new Note("Bikes", "Yammaha, Honda, KTM, Aprilia");
            Note     note3    = new Note("Tyres", "Tigar, Fulda, Sava,Dunlop");
            Notebook notebook = new Notebook();

            notebook.AddNote(note1);
            notebook.AddNote(note2);
            notebook.AddNote(note3);
            notebook.RemoveNote(note2);

            IAbstractIterator notebookIterator = notebook.GetIterator();

            while (!notebookIterator.IsDone)
            {
                notebookIterator.Current.Show();
                notebookIterator.Next();
            }
        }
Пример #5
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));
        }