public void ToDoItemToString()
        {
            ToDoItem item     = new ToDoItem(new string[] { "1", "TestToDo1", "2018-11-03", "0", "1" });
            string   expected = "1;TestToDo1;2018-11-03;0;1";

            Assert.AreEqual(expected, item.ToString());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            note note = new note("Naslov", "text, tijelo poruke");

            note.Show();

            StringBuilder sbTitle  = new StringBuilder("Naslov p");
            StringBuilder sbBody   = new StringBuilder("Text pp0");
            Notebook      notebook = new Notebook();

            for (int i = 0; i < 8; i++)
            {
                sbTitle.Append('w', i / 2);
                sbBody.Append('b', i / 3);
                notebook.AddNote(new note(sbTitle.ToString(), sbBody.ToString()));
            }

            CIterator iterator = new CIterator(notebook);

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

            notebook.Clear();

            CareTaker careTaker = new CareTaker();
            ToDoItem  tdi1      = new ToDoItem("naslov1", "text1", DateTime.Now);
            ToDoItem  tdi2      = new ToDoItem("naslov12", "text12", DateTime.Now);
            ToDoItem  tdi3      = new ToDoItem("naslov123", "text123", DateTime.MinValue);
            ToDoItem  tdi4      = new ToDoItem("naslov1234", "text1234", DateTime.MaxValue);

            tdi1.AddStateCT(careTaker);
            tdi2.AddStateCT(careTaker);
            tdi3.AddStateCT(careTaker);
            tdi4.AddStateCT(careTaker);

            ToDoItem getStateTdi = new ToDoItem("", "", DateTime.MinValue);

            getStateTdi.RestoreState(careTaker.GetByTitle("naslov12"));

            Console.WriteLine(getStateTdi.ToString());

            HomeThermostat termostat1    = new HomeThermostat();
            HomeThermostat termostat2    = new HomeThermostat();
            CarThermostat  termostatAuto = new CarThermostat();
            WeatherStation station       = new WeatherStation(44);

            station.AddObserver(termostat1);
            station.AddObserver(termostat2);
            station.AddObserver(termostatAuto);
            station.SetTemperature(22);
            station.SetTemperature(2);
        }
Esempio n. 3
0
        static void Main()
        {
            CompositeItem items = new("DevelopSite", "All the work for developing my website");

            CompositeItem devClientSide = new("DevelopClient", "All the work for developing the front end");
            CompositeItem devServerSide = new("DevelopServer", "All the work for developing the back end");

            items.Add(devClientSide);
            items.Add(devServerSide);

            devClientSide.Add(SampleItems.DesignGui);
            devClientSide.Add(SampleItems.ProgramGui);
            devClientSide.Add(SampleItems.CallNewYork);
            devClientSide.Add(SampleItems.BuyCoffee);

            CompositeItem initialDevServerSide = new("DevelopServerFirstTry", "All the work for developing the back end");
            CompositeItem retryDevServerSide   = new("DevelopServerSecondTry", "All the work for developing the back end again");

            devServerSide.Add(initialDevServerSide);
            devServerSide.Add(retryDevServerSide);

            initialDevServerSide.Add(SampleItems.DesignApi);
            initialDevServerSide.Add(SampleItems.ProgramApi);
            initialDevServerSide.Add(SampleItems.BuyBook);

            retryDevServerSide.Add(SampleItems.ReProgramApi);
            retryDevServerSide.Add(SampleItems.CallNewYorkAgain);
            retryDevServerSide.Add(SampleItems.BuyNewServer);

            items.Add(new PurchaseItem("Champagne", "A bottle of bubbly to celebrate", 35));

            Console.WriteLine(items.ToString());

            Console.WriteLine();

            Console.WriteLine($"Total cost is {items.Cost:C}.");
            Console.WriteLine($"Total duration is {items.Hours} hours.");

            Console.WriteLine();

            ToDoItem found = items.Find("BuyNewServer");

            Console.WriteLine(found?.ToString() ?? "Not found");
        }
 private void ShowString(ToDoItem item)
 {
     _builder.Append(new string(' ', _indent * 4)).AppendLine(item.ToString());
 }