Пример #1
0
        static void Main(string[] args)
        {
            //Zad 1.
            Notebook notebook = new Notebook();

            notebook.AddNote(new Note("Taxi", "5 dollars"));
            notebook.AddNote(new Note("Forrest Gump", "Run Forrest run!"));
            notebook.AddNote(new Note("Lord of the rings", "What about second breakfast?"));
            IAbstractIterator notebookIterator = notebook.GetIterator();

            notebookIterator.First().Show();
            while (notebookIterator.Next() != null)
            {
                notebookIterator.Current.Show();
            }

            //Zad 2.

            Box box = new Box();

            box.AddProduct(new Product("Keyboard", 199.99));
            box.AddProduct(new Product("Mouse", 249.99));
            box.AddProduct(new Product("Headset", 299.99));
            IBoxIterator boxIterator = box.GetIterator();

            Console.WriteLine(boxIterator.First().ToString());
            while (boxIterator.Next() != null)
            {
                Console.WriteLine(boxIterator.Current.ToString());
            }
        }
Пример #2
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());
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            //prvi
            Notebook notebook = new Notebook();

            notebook.AddNote(new Note("Error", "Important"));
            notebook.AddNote(new Note("Info", "Important"));
            notebook.AddNote(new Note("Signal", "Important"));
            notebook.AddNote(new Note("Thing", "Important"));

            IAbstractIterator iterator = notebook.GetIterator();

            while (!iterator.IsDone)
            {
                iterator.Current.Show();
                iterator.Next();
            }
            //drugi
            Box box = new Box();

            box.AddProduct(new Product("Fish", 10.99));
            box.AddProduct(new Product("Chips", 10.99));
            box.AddProduct(new Product("Meat", 10.99));
            box.AddProduct(new Product("Soda", 10.99));

            IAbstractIteratorBox iteratorBox = box.GetIterator();

            while (!iteratorBox.IsDone)
            {
                Console.WriteLine(iteratorBox.Current.ToString());
                iteratorBox.Next();
            }

            //treci
            CareTaker history = new CareTaker();

            ToDoItem item = new ToDoItem("Mission", "Important", DateTime.Now);

            Console.WriteLine(item.ToString());
            history.Store(item.StoreState());
            item.Rename("Task");
            Console.WriteLine(item.ToString());
            item.RestoreState(history.PreviousState());
            Console.WriteLine(item.ToString());

            //cetvrti

            BankAccount account      = new BankAccount("Me", "Here", 500.0m);
            MementoBank previosState = account.StoreState();

            Console.WriteLine(account.ToString());
            account.UpdateBalance(1000.0m);
            Console.WriteLine(account.ToString());
            account.RestoreState(previosState);
            Console.WriteLine(account.ToString());
        }
Пример #4
0
        public void Display()
        {
            IAbstractIterator iterator = CreateIterator();

            Console.WriteLine("Prolazim kroz listu dana:");
            for (IRasporedEmisija item = iterator.First(); !iterator.IsDone; item = iterator.Next())
            {
                Console.WriteLine(((DanComposite)item).Dan.Naziv);
            }
        }
Пример #5
0
        public void Display()
        {
            IAbstractIterator iterator = CreateIterator();

            Console.WriteLine("Prolazim kroz listu emisija:");
            for (IRasporedEmisija item = iterator.First(); !iterator.IsDone; item = iterator.Next())
            {
                Console.WriteLine(((EmisijaLeaf)item).Emisija.Emisija.naziv);
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            Box box = new Box();

            box.AddProduct(new Product("Product 1", 5));
            box.AddProduct(new Product("Product 2", 10));

            IAbstractIterator iterator = box.GetIterator();

            while (iterator.IsDone != true)
            {
                Console.WriteLine(iterator.Current.ToString());
                iterator.Next();
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            Notebook notebook = new Notebook();

            notebook.AddNote(new Note("Test title1", "test,test!"));
            notebook.AddNote(new Note("Test title2", "test,test!"));
            notebook.AddNote(new Note("Test title3", "test,test!"));

            IAbstractIterator iterator = notebook.GetIterator();

            for (Note note = iterator.First(); iterator.IsDone == false; note = iterator.Next())
            {
                note.Show();
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            Box box = new Box();

            box.AddProduct(new Product("Monopoly", 80));
            box.AddProduct(new Product("Player's Unknown Battlegrounds", 200));
            box.AddProduct(new Product("Coffee mug", 20));

            IAbstractIterator iterator = box.GetIterator();

            for (Product product = iterator.First(); iterator.IsDone == false; product = iterator.Next())
            {
                Console.WriteLine(product.ToString());
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            Notebook notebook = new Notebook();

            notebook.AddNote(new Note("Zadatak 1", "Probaaa"));


            IAbstractIterator iterator = notebook.GetIterator();

            do
            {
                iterator.Current.Show();
                iterator.Next();
            } while (iterator.IsDone != true);
        }
Пример #10
0
        static void Main(string[] args)
        {
            Note     schoolNote  = new Note("Study schedule", "programming, english");
            Note     gymNote     = new Note("no pain no gain", "100 push ups, 100 sit ups");
            Note     morningNote = new Note("Good morning!", "You can do this!");
            Notebook notebook    = new Notebook();

            notebook.AddNote(schoolNote);
            notebook.AddNote(gymNote);
            notebook.AddNote(morningNote);
            IAbstractIterator iterator = notebook.GetIterator();

            for (Note note = iterator.First(); iterator.IsDone == false; note = iterator.Next())
            {
                note.Show();
            }
        }
Пример #11
0
        static void Main(string[] args)
        {
            Product shirt     = new Product("100% cotton", 100);
            Product videoGame = new Product("PG-13", 300);
            Product shoes     = new Product("yeezy", 10000);
            Box     box       = new Box();

            box.AddProduct(shirt);
            box.AddProduct(videoGame);
            box.AddProduct(shoes);
            IAbstractIterator iterator = box.GetIterator();

            for (Product product = iterator.First(); iterator.IsDone == false; product = iterator.Next())
            {
                Console.WriteLine(product.ToString());
            }
        }
Пример #12
0
        public int Prihod()
        {
            int zbrojPrihoda           = 0;
            IAbstractIterator iterator = this.CreateIterator();

            while (iterator.hasNext())
            {
                IRasporedEmisija raspored = iterator.Next();
                var vrsta = ((EmisijaLeaf)raspored).Emisija.Emisija.VrstaEmisije;
                if (vrsta != null)
                {
                    if (((EmisijaLeaf)raspored).Emisija.Emisija.vrsta.Reklama == 1)
                    {
                        zbrojPrihoda += ((EmisijaLeaf)raspored).Emisija.Emisija.vrsta.Trajanje;
                    }
                }
            }
            return(zbrojPrihoda);
        }
Пример #13
0
        static void Main(string[] args)
        {
            var myNotes = new List <Note>()
            {
                new Note("prva biljeska", "korona"),
                new Note("druga biljeska", "karantena"),
            };
            Notebook myNotebook = new Notebook(myNotes);
            Note     myNewNote  = new Note("treca biljeska", "samoizolacija");

            myNotebook.AddNote(myNewNote);
            IAbstractIterator iterator = myNotebook.GetIterator();
            Note toPrint;

            for (toPrint = iterator.First(); iterator.IsDone == false; toPrint = iterator.Next())
            {
                toPrint.Show();
            }
        }
Пример #14
0
        static void Main(string[] args)
        {
            var myProducts = new List <Product>()
            {
                new Product("prvi proizvod", 1.23),
                new Product("drugi proizvod", 4.56),
            };
            Box     myBox        = new Box(myProducts);
            Product myNewProduct = new Product("treci proizvod", 7.89);

            myBox.AddProduct(myNewProduct);
            IAbstractIterator iterator = myBox.GetIterator();
            Product           toPrint;

            for (toPrint = iterator.First(); iterator.IsDone == false; toPrint = iterator.Next())
            {
                Console.WriteLine(toPrint.ToString());
            }
        }
Пример #15
0
        static void Main(string[] args)
        {
            Note z1 = new Note("zabiljeska1", "Ovo je zabiljeska 1");
            Note z2 = new Note("zabiljeska2", "Ovo je zabiljeska 2");
            Note z3 = new Note("zabiljeska3", "Ovo je zabiljeska 3");

            Notebook biljeznica = new Notebook();

            biljeznica.AddNote(z1);
            biljeznica.AddNote(z2);
            biljeznica.AddNote(z3);

            IAbstractIterator iterator = biljeznica.GetIterator();

            while (!iterator.IsDone)
            {
                iterator.Current.Show();
                iterator.Next();
            }
        }
Пример #16
0
        public int Prihod()
        {
            IzracunPrihoda    izracun  = new IzracunPrihoda();
            IAbstractIterator iterator = this.CreateIterator();
            IRasporedEmisija  raspored = iterator.First();

            while (!iterator.IsDone)
            {
                var vrsta = ((EmitiranjeEmisija)raspored).Emisija.VrstaEmisije;
                if (vrsta != null)
                {
                    if (((EmitiranjeEmisija)raspored).Emisija.vrsta.Reklama == 1)
                    {
                        izracun.posjeti(((EmitiranjeEmisija)raspored).Emisija.vrsta);
                    }
                }
                raspored = iterator.Next();
            }
            return(izracun.getUkupanPrihod());
        }
Пример #17
0
        static void Main(string[] args)
        {
            Product p1 = new Product("novcanik", 250);
            Product p2 = new Product("bokal za vodu", 25);
            Product p3 = new Product("ulazna vrata", 2600);

            Box kutija = new Box();

            kutija.AddProduct(p1);
            kutija.AddProduct(p2);
            kutija.AddProduct(p3);

            IAbstractIterator iterator = kutija.GetIterator();

            while (!iterator.IsDone)
            {
                Console.WriteLine(iterator.Current);
                iterator.Next();
            }
        }
Пример #18
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();
            }
        }
Пример #19
0
        static void Main(string[] args)
        {
            Box     box      = new Box();
            Product product1 = new Product("Product1", 1);
            Product product2 = new Product("Product2", 2);
            Product product3 = new Product("Product3", 3);

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

            IAbstractIterator iterator = box.GetIterator();

            Product currentProduct = iterator.First();

            while (iterator.IsDone == false)
            {
                Console.WriteLine(currentProduct.ToString());
                currentProduct = iterator.Next();
            }
        }
Пример #20
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();
            }
        }
Пример #21
0
        static void Main(string[] args)
        {
            Notebook notebook = new Notebook();
            Note     note1    = new Note("Title1", "Text1");
            Note     note2    = new Note("Title2", "Text2");
            Note     note3    = new Note("Title3", "Text3");

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

            IAbstractIterator iterator = notebook.GetIterator();

            Note currentNote = iterator.First();

            while (iterator.IsDone == false)
            {
                currentNote.Show();
                currentNote = iterator.Next();
            }
        }
Пример #22
0
        static void Main(string[] args)
        {
            //1. zadatak

            List <Note> notes = new List <Note>();

            notes.Add(new Note("Note 1", "Text 1"));
            notes.Add(new Note("Note 2", "Text 2"));
            notes.Add(new Note("Note 3", "Text 3"));

            Notebook          notebook = new Notebook(notes);
            IAbstractIterator iterator = notebook.GetIterator();

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



            //2. Zadatak

            List <Product> products = new List <Product>();

            products.Add(new Product("Product 1", 4));
            products.Add(new Product("Product 2", 7));
            products.Add(new Product("Product 3", 14));

            Box box = new Box(products);

            /*IAbstractIterator iterator = box.GetIterator();
             * for (Product product = iterator.First(); !iterator.IsDone; product = iterator.Next())
             * {
             *  Console.WriteLine(product.ToString());
             * }*/


            //3. Zadatak

            ToDoItem toDoItem = new ToDoItem("Razvoj programske podrške objektno orijentiranim načelima", "Predati zadaću.", new DateTime(2020, 6, 3, 20, 00, 00));

            CareTaker careTaker = new CareTaker();

            careTaker.SetLast(toDoItem.StoreState());

            toDoItem.Rename("Predati sve labose");
            toDoItem.ChangeTask("Naučiti za predrok.");
            toDoItem.ChangeTimeDue(new DateTime(2020, 6, 5, 17, 00, 00));
            careTaker.SetLast(toDoItem.StoreState());

            toDoItem.Rename("Napraviti i predati seminar");
            toDoItem.ChangeTask("Usmeni ispit");
            toDoItem.ChangeTimeDue(new DateTime(2020, 6, 15, 22, 00, 00));
            careTaker.SetLast(toDoItem.StoreState());

            toDoItem.Rename("Učiti za ispitne rokove");
            toDoItem.ChangeTask("Položiti kolegije na ispitnim rokovima.");
            toDoItem.ChangeTimeDue(new DateTime(2020, 6, 28, 16, 59, 59));

            Console.WriteLine(toDoItem.ToString());    //ispisuje se zadnje stanje koje je dodano

            toDoItem.RestoreState(careTaker.GetLast());

            Console.WriteLine(toDoItem.ToString());    //ispisuje se treće stanje

            toDoItem.RestoreState(careTaker.GetLast());

            Console.WriteLine(toDoItem.ToString());    //ispisuje se drugo stanje

            toDoItem.RestoreState(careTaker.GetLast());

            Console.WriteLine(toDoItem.ToString());    //ispisuje se prvo stanje

            Console.ReadKey();


            //4. Zadatak

            BankAccount account = new BankAccount("Domagoj Voćanec", "Ulica Prva desno", 7500);

            Console.WriteLine(account.ToString());
            Memento bankAccountSave = account.Store();

            account.ChangeOwnerAddress(" Ulica Prva lijevo ");

            account.UpdateBalance(+2500);
            Console.WriteLine("\n" + account.ToString() + "\n");

            account.Restore(bankAccountSave);
            Console.WriteLine(account.ToString());

            Console.ReadKey();
        }