Exemple #1
0
 public void SetCalculator(CalculatePercentile calc)
 {
     this.stratCalc = calc;
 }
Exemple #2
0
        static void Main(string[] args)
        {
            #region Setup
            GenerateNumbers     stratGen  = null;
            CalculatePercentile stratCalc = null;

            Console.WriteLine("Number generation method:");
            int genMethod = Convert.ToInt32(Console.ReadLine());
            switch (genMethod)
            {
            case 1:
                Console.WriteLine("Enter lower limit, upper limit and step");
                double lower = Convert.ToDouble(Console.ReadLine());
                double upper = Convert.ToDouble(Console.ReadLine());
                double step  = Convert.ToDouble(Console.ReadLine());
                stratGen = new StrategyGenerateNumbers1(lower, upper, step);
                break;

            case 2:
                Console.WriteLine("Enter standard deviation, mean and number of elements");
                double stdDev = Convert.ToDouble(Console.ReadLine());
                double mean   = Convert.ToDouble(Console.ReadLine());
                int    n      = Convert.ToInt32(Console.ReadLine());
                stratGen = new StrategyGenerateNumbers2(mean, stdDev, n);
                break;

            case 3:
                Console.WriteLine("Broj elemenata:");
                int number = Convert.ToInt32(Console.ReadLine());
                stratGen = new StrategyGenerateNumbers3(number);
                break;
            }

            Console.WriteLine("Percentile calculation method:");
            int percMethod = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Wanted percentile:");
            double percentile = Convert.ToDouble(Console.ReadLine());
            switch (percMethod)
            {
            case 1:
                stratCalc = new StrategyCalculatePercentile1(percentile);
                break;

            case 2:
                stratCalc = new StrategyCalculatePercentile2(percentile);
                break;

            case 3:
                stratCalc = new StrategyGeneratePercentile3(new StrategyCalculatePercentile1(percentile),
                                                            new StrategyCalculatePercentile2(percentile));
                break;
            }
            #endregion

            DistributionTester tester = new DistributionTester();
            tester.SetGenerator(stratGen);
            tester.SetCalculator(stratCalc);
            tester.Generate();
            tester.Calculate();
            tester.doWrite();

            Console.ReadKey();
        }
Exemple #3
0
 public StrategyGeneratePercentile3(CalculatePercentile gen1, CalculatePercentile gen2)
 {
     this._gen1 = gen1;
     this._gen2 = gen2;
 }