示例#1
0
        private void GetDailyEODDate(DataBase tprdata, DateTime datumVon, ListView.SelectedListViewItemCollection selecteditem)
        {
            ArrayLoader loader = new ArrayLoader();

            //securities are identified with a unique symbol number
            int bubu = Int32.Parse(selecteditem[0].SubItems[2].Text);

            int[] symbolNr = new int[1]
            {
                bubu
                //   78303,          //555750.ETR        Dt.Telekom
                //169286,         //710000.ETR        Daimler AG
                //78275,          //519000.ETR        BWM ST
                //78340,          //766403.ETR        VW ST
                //78267           //823212.ETR        Lufthansa
            };
            //DateTime datumVon = new DateTime(2013, 8, 1);    //start date is 08/01/2013
            DateTime datumBis = DateTime.Now;               //end date is today

            JahreschartCollection jahresCol = loader.Jahrescharts(symbolNr, datumVon, datumBis) as JahreschartCollection;

            if (jahresCol != null)
            {
                //the JahresChartCollection contains all end-of-day charts...
                Jahreschart     c  = new Jahreschart();
                IChartTimeRange it = (IChartTimeRange)c;
                it.TimeRange(datumVon, datumBis);

                foreach (Jahreschart chart in jahresCol)
                {
                    ////...that can be read now...
                    //Debug.WriteLine(Environment.NewLine);
                    //foreach (IJahreschartEintrag entry in chart)
                    //{
                    //    Debug.WriteLine("{0}  {1}  {2}  {3}  {4}", entry.Zeit.ToShortDateString(), entry.Open, entry.High, entry.Low, entry.Close);
                    //}
                    _exportdata = new List <string[]>();
                    foreach (IJahreschartEintrag entry in chart)
                    {
                        //TPRTIntradayChartEintrag = (IIntradayChartEintrag)TPRTIntradayChart[i];
                        string[] tempdata = new string[7];
                        tempdata[0] = entry.Zeit.ToString("dd.MM.yyyy");// + " " + entry.Zeit.ToString("hhmmss");
                        tempdata[1] = entry.Open.ToString();
                        tempdata[2] = entry.High.ToString();
                        tempdata[3] = entry.Low.ToString();
                        tempdata[4] = entry.Close.ToString();
                        tempdata[5] = entry.Volume.ToString();
                        tempdata[6] = entry.OpenInterest.ToString();

                        _exportdata.Add(tempdata);
                        //Console.WriteLine("Time: " + TPRTIntradayChartEintrag.Zeit.ToString() + " Value: " + TPRTIntradayChartEintrag.Kurs.ToString());
                        //Console.WriteLine(TPRTIntradayChartEintrag.Volume.ToString());
                    }
                    this.lbl_data_loaded.Text = _exportdata.Count + " rows of data loaded.";
                }
            }
        }
        public void It_Should_Take_An_Array_Of_Templates()
        {
            var loader = new ArrayLoader(new Dictionary<string, string>
            {
                { "Foo", "I'm {{Foo}}" },
                { "Bar", "I'm {{Bar}}" }
            });

            Assert.Equal(2, loader.TemplateCache.Count);
        }
        public void It_Should_Load_Items_From_Template_If_Exists()
        {
            var loader = new ArrayLoader(new Dictionary<string, string>
            {
                { "Foo", "I'm {{Foo}}" },
                { "Bar", "I'm {{Bar}}" }
            });

            Assert.Equal("I'm {{Foo}}", loader.Load("Foo"));
            Assert.Null(loader.Load("Foo2"));
        }
 public void It_Should_Create_A_Clone_Of_Passed_Values()
 {
     var arr = new Dictionary<string, string>
     {
         {"Foo", "I'm {{Foo}}"},
         {"Bar", "I'm {{Bar}}"}
     };
     var loader = new ArrayLoader(arr);
     Assert.Equal(2, loader.TemplateCache.Count);
     arr.Add("FooBar", "{{Foo}}{{Bar}}");
     Assert.Equal(2, loader.TemplateCache.Count);
 }
示例#5
0
        /* Monotoniczność
         * Dane: Ciąg liczb rzeczywistych
         * Cel: Sprawdzić monotoniczność ciągu
         * Wynik: Rodzaj monotoniczności (lub jej brak)
         */

        /* Zadanie 1
         * Dane: Ciąg liczb rzeczywistych
         * Cel: Sprawdzić, czy ciąg jest arytmetyczny
         * Wynik: Stwierdzenie, czy ciag jest arytmetyczny
         */

        /* Zadanie 2
         * Dane: Ciąg liczb rzeczywistych
         * Cel: Sprawdzić, czy ciąg jest geometryczny
         * Wynik: Stwierdzenie, czy ciąg jest geometryczny
         */

        /* Zadanie 3
         * Dane: Liczba naturalna większa od 1
         * Cel: Rozłożyć daną liczbę na czynniki pierwsze
         * Wynik: Czynniki pierwsze składające się na daną liczbę (tablica liczb całkowitych)
         */

        /* Zadanie 4
         * Dane: 2 liczby naturalne (nie mniejsze niż 1)
         * Cel: Obliczyć największy wspólny dzielnik danych liczb
         * Wynik: NWD danych liczb (liczba całkowita)
         */

        /* Zadanie 5
         * Dane: 2 liczby naturalne (nie mniejsze niż 1)
         * Cel: Obliczyć najmniejszą wspólną wielokrotność danych liczb
         * Wynik: NWW danych liczb (liczba całkowita)
         */

        static void Main(string[] args)
        {
            ArrayLoader AL = new ArrayLoader();

tasksel:
            Selector TaskSel = new Selector(new string[] { "Sprawdz, czy podany ciag jest arytmetyczny", "Sprawdz, czy podany ciag jest geometryczny, z pierwszym wyrazem roznym od 0", "Rozloz liczbe naturalna na czynniki pierwsze", "NWD dwoch liczb naturalnych", "NWW dwoch liczb naturalnych", "Monotonicznosc ciagu" });
            int selection = TaskSel.Select();

            switch (selection)
            {
            case 0:
                Environment.Exit(0);
                break;

            case 1:
                goto arithm;

            case 2:
                goto geom;

            case 3:
                goto factor;

            case 4:
                goto NWD;

            case 5:
                goto NWW;

            case 6:
                goto mono;

            default:
                goto tasksel;
            }

mono:
            double[] monodata = AL.LoadDoubleArray();
            byte     mono     = Monotonicity(monodata);

            switch (mono)
            {
            case 0:
                Console.WriteLine("Ciag jest niemonotoniczny.");
                break;

            case 1:
                Console.WriteLine("Ciag jest staly.");
                break;

            case 2:
                Console.WriteLine("Ciag jest rosnacy.");
                break;

            case 3:
                Console.WriteLine("Ciag jest malejacy.");
                break;

            case 4:
                Console.WriteLine("Ciag jest niemalejacy.");
                break;

            case 5:
                Console.WriteLine("Ciag jest nierosnacy.");
                break;
            }
            Console.ReadKey();
            goto tasksel;

arithm:
            double[] arithmetic = AL.LoadDoubleArray();
            if (arithmetic.Length < 3)
            {
                Console.WriteLine("Nie mozna okreslic, czy ciag jest arytmetyczny.");
            }
            else
            {
                double diff = arithmetic[1] - arithmetic[0];
                for (int i = 2; i < arithmetic.Length; i++)
                {
                    if (arithmetic[i] - diff != arithmetic[i - 1])
                    {
                        Console.WriteLine("Ciag nie jest arytmetyczny.");
                        Console.ReadKey();
                        goto tasksel;
                    }
                }
                Console.WriteLine("Ciag jest arytmetyczny.");
            }
            Console.ReadKey();
            goto tasksel;

geom:
            double[] geometric = AL.LoadDoubleArray();
            if (geometric.Length < 3)
            {
                Console.WriteLine("Nie mozna okreslic, czy ciag jest geometryczny.");
            }
            else
            {
                double multiplier = geometric[1] / geometric[0];
                for (int i = 2; i < geometric.Length; i++)
                {
                    if (geometric[i] / multiplier != geometric[i - 1])
                    {
                        Console.WriteLine("Ciag nie jest geometryczny.");
                        Console.ReadKey();
                        goto tasksel;
                    }
                }
                Console.WriteLine("Ciag jest geometryczny.");
            }
            Console.ReadKey();
            goto tasksel;

factor:
            Console.Clear();
            Console.Write("Podaj liczbe naturalna wieksza od 1: ");
            string factInput   = Console.ReadLine();
            int    toFactorize = 0;

            if (!int.TryParse(factInput, out toFactorize) || toFactorize <= 1)
            {
                goto factor;
            }
            Console.WriteLine("Rozklad na czynniki pierwsze:");
            Console.WriteLine(string.Join("  ", Factorize(toFactorize)));
            Console.ReadKey();
            goto tasksel;

NWD:
            Console.Clear();
            Console.WriteLine("Podaj dwie liczby naturalne dodatnie:"); // Wprawdzie dane są liczby naturalne, ale nie ma sensu liczyć NWD dla 0 i czegokolwiek.
            string nwdInA  = Console.ReadLine();
            string nwdInB  = Console.ReadLine();
            int    nwdNumA = -1;
            int    nwdNumB = -1;

            if (!int.TryParse(nwdInA, out nwdNumA) || !int.TryParse(nwdInB, out nwdNumB) || nwdNumA < 1 || nwdNumB < 1)
            {
                goto NWD;
            }
            Console.WriteLine("Najwiekszy wspolny dzielnik: " + NWD(nwdNumA, nwdNumB));
            Console.ReadKey();
            goto tasksel;

NWW:
            Console.Clear();
            Console.WriteLine("Podaj dwie liczby naturalne dodatnie:"); // j.w.
            string nwwInA  = Console.ReadLine();
            string nwwInB  = Console.ReadLine();
            int    nwwNumA = -1;
            int    nwwNumB = -1;

            if (!int.TryParse(nwwInA, out nwwNumA) || !int.TryParse(nwwInB, out nwwNumB) || nwwNumA < 1 || nwwNumB < 1)
            {
                goto NWW;
            }
            Console.WriteLine("Najmniejsza wspolna wielokrotnosc: " + NWW(nwwNumA, nwwNumB));
            Console.ReadKey();
            goto tasksel;
        }
示例#6
0
        static void Main(string[] args)
        {
            ArrayLoader AL = new ArrayLoader();
            Selector    TS = new Selector(new string[] { "Sprawdz, czy liczba jest pierwsza", "Liczby z przedzialu niepodzielne przez liczby z tablicy" });

tasksel:
            int sel = TS.Select();

            switch (sel)
            {
            case 0:
                Environment.Exit(0);
                break;

            case 1:
                goto prime;

            case 2:
                goto nondiv;

            default:
                goto tasksel;
            }
prime:
            Console.Clear();
            Console.Write("Podaj liczbe calkowita > ");
            string primeStr   = Console.ReadLine();
            int    primeInput = 0;

            if (!int.TryParse(primeStr, out primeInput))
            {
                goto prime;
            }
            bool isPrime = Prime(primeInput);

            if (isPrime)
            {
                Console.WriteLine("Podana liczba jest pierwsza.");
            }
            else
            {
                Console.WriteLine("Podana liczba nie jest pierwsza.");
            }
            Console.ReadKey();
            goto tasksel;
nondiv:
            Console.Clear();
            Console.Write("Podaj gorna granice sprawdzania (wieksza lub rowna 2) > ");
            string ndNumberStr = Console.ReadLine();
            int    ndNumber    = 0;

            if (!int.TryParse(ndNumberStr, out ndNumber))
            {
                goto nondiv;
            }
            if (ndNumber < 2)
            {
                goto nondiv;
            }
            int[] ndArray = AL.LoadIntArray();
            for (int i = 0; i < ndArray.Length; i++)
            {
                if (ndArray[i] > ndNumber)
                {
                    Console.WriteLine("Element #$0 wprowadzonej tablicy jest poza zakresem sprawdzania.", i + 1);
                    Console.ReadKey();
                    goto nondiv;
                }
            }
            Console.Clear();
            Console.WriteLine("Wynik dla przedzialu $0 i podanej tablicy to nastepujace liczby:", ndNumber);
            string ndResult = string.Join(", ", NonDivisible(ndNumber, ndArray));

            Console.WriteLine(ndResult);
            Console.ReadKey();
            goto tasksel;
        }