public CalculatorArithmetic(IFormatting formatting, ICalculate calculate, IInput input, IOutput output)
 {
     this.Input      = input;
     this.Output     = output;
     this.Formatting = formatting;
     this.Calculate  = calculate;
 }
        /// <summary>
        /// </summary>
        public HashEvaluationDialog()
        {
            _calculate            = new Calculate();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            InitializeComponent();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the first number");
            string input = Console.ReadLine();

            Console.WriteLine("Enter the second number");
            string input1 = Console.ReadLine();
            double a, b;
            bool   result = Double.TryParse(input, out a);

            if (!result)
            {
                Console.WriteLine("Please enter the  number");
                input1 = Console.ReadLine();
                return;
            }
            bool result1 = Double.TryParse(input1, out b);

            if (!result1)
            {
                Console.WriteLine("Please Enter the number");
                return;
            }
            Console.WriteLine("Please Enter 1 for Addition 2 for Subtraction");
            CalculateFactory calculateFactory = new CalculateFactory();
            ICalculate       obj = calculateFactory.GetCalculations(Console.ReadLine());

            if (obj != null)
            {
                obj.Calculate(a, b);
            }
        }
        public ExpressionTask(string expId, string expName, ExpressionCalculateType expCalculateType, int timerInterval, string script, ICalculate calc)
        {
            Id   = expId;
            Name = expName;

            Script = script;

            PatternDataList = new List <string>();

            PatternDataList.AddRange(GetPatternDataList(Script));

            if (calc == null)
            {
                CalculateOperator = new ExpressionCalculate($"{Id}_result");
            }
            else
            {
                CalculateOperator = calc;
            }

            _timer           = new System.Timers.Timer(timerInterval);
            _timer.Elapsed  += OnTimedEvent;
            _timer.AutoReset = true;

            TimerInterval = timerInterval;

            ExpressionCalculateType = expCalculateType;
        }
Exemple #5
0
        static void MainOLD()
        {
            Console.WriteLine("Enter first number");
            string input = Console.ReadLine();
            double number1, number2;
            bool   result = Double.TryParse(input, out number1);

            if (!result)
            {
                Console.WriteLine("Please enter a number");
                return;
            }

            Console.WriteLine("Enter second number");
            result = Double.TryParse(Console.ReadLine(), out number2);
            if (!result)
            {
                Console.WriteLine("Please enter a number");
                return;
            }

            Console.WriteLine("Enter add, subtract or divide bitch");
            CalculateFactory factory = new CalculateFactory();
            ICalculate       objectA = factory.GetCalculation(Console.ReadLine());

            // Divide objectA = new Divide();
            objectA.Calculate(number1, number2);
            MainOLD();
        }
Exemple #6
0
        public ICalculate GetCalculate(string type)
        {
            ICalculate obj = null;

            if (type.ToLower().Equals("add"))
            {
                obj = new Add();
            }
            else if (type.ToLower().Equals("substract"))
            {
                obj = new Add();
            }
            else if (type.ToLower().Equals("multiply"))
            {
                obj = new Multiply();
            }
            else if (type.ToLower().Equals("divide"))
            {
                obj = new Add();
            }
            else
            {
                Console.WriteLine("cannot implement");
            }
            return(obj);
        }
 public EventToList(IFilter filter, ICalculate calculator, ISeparationCondition sepCond)
 {
     this._calculator          = calculator;
     this._filter              = filter;
     this._separationCondition = sepCond;
     this._filter.RelevantAirplanesReceivedEvent += ToList;
 }
Exemple #8
0
    protected void When_CalculateBtn_Clicked(object sender, EventArgs e)
    {
        try
        {
            //get operands
            int operandX = Convert.ToInt32(Entry_OperandX.Text);
            int operandY = Convert.ToInt32(Entry_OperandY.Text);

            //get operator
            string oper = ComboBox_Operators.ActiveText;

            //produce suitable object depends on oper
            ICalculate cal = Factory.ProduceCalculateTool(oper);

            //calculate
            int result = cal.Calculate(operandX, operandY);

            //show result
            Label_Result.Text = string.Format("Result          : {0}", result.ToString());
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Exemple #9
0
        private void InitWindow(string tagWindowId, string tagWindowName, bool isOpenWindow, int windowInterval, int delayWindowCount, ICalculate calc)
        {
            Id               = tagWindowId;
            Name             = tagWindowName;
            WindowInterval   = windowInterval;
            DelayWindowCount = delayWindowCount;

            if (calc == null)
            {
                CalculateOperator = new Avg($"{Id}_avg");
            }
            else
            {
                CalculateOperator = calc;
            }

            _cache = new DataPool();

            _delayCache = new ConcurrentQueue <DataPool>();

            SlidTimeWindow(DateTime.Now);

            _timer           = new System.Timers.Timer(1000);
            _timer.Elapsed  += OnTimedEvent;
            _timer.AutoReset = true;

            IsOpenWindow = isOpenWindow;
        }
 public DriverInformationService(IDriverReader driverReader, ICalculate calculate, IDataReader dataReader, IDriverQualifyingReader driverQualifyingReader)
 {
     _driverReader           = driverReader;
     _calculate              = calculate;
     _dataReader             = dataReader;
     _driverQualifyingReader = driverQualifyingReader;
 }
Exemple #11
0
        public JsonResult Calculete(CalculeteRequest calculeteRequest)
        {
            ICalculate calculate            = _calculate;
            List <CalculateResponse> result = calculate.Moving(calculeteRequest);

            return(new JsonResult(result));
        }
Exemple #12
0
        static void TestMasterNode()
        {
            Console.WriteLine("请输入任务数:");

            _initTagNum = int.Parse(Console.ReadLine());

            while (true)
            {
                for (int i = 0; i < _initTagNum; i++)
                {
                    string key = i.ToString("0000");
                    if (!execution.TaskManager.ContainsWindow(key))
                    {
                        _windowInterval = Calc.GetRandomWindowInterval();
                        _calculate      = Calc.GetAggRandomCalculate();

                        execution.TaskManager.AddWindowTask(key, $"窗口{key}", _windowInterval, _delayWindowCount, _calculate);

                        IMetaData md = Calc.GetMetaData(key, TestCommon.DataType.RtData, _delayWindowCount, _windowInterval);

                        execution.TaskManager.AddMetaData(key, md);
                    }
                    else
                    {
                        IMetaData md = Calc.GetMetaData(key, TestCommon.DataType.RtData, _delayWindowCount, _windowInterval);
                        execution.TaskManager.AddMetaData(key, md);
                    }
                }
                Thread.Sleep(1000);
            }
        }
Exemple #13
0
        static void Main()
        {
            Console.WriteLine("Enter first number");
            string input = Console.ReadLine();
            double num1, num2;
            bool   result = Double.TryParse(input, out num1);

            if (!result)
            {
                Console.WriteLine("Please enter a number");
                return;
            }
            Console.WriteLine("Enter second number");
            result = Double.TryParse(Console.ReadLine(), out num2);
            if (!result)
            {
                Console.WriteLine("Please enter a number");
                return;
            }

            Console.WriteLine("Enter Add, Subtract or Divide");
            CalculateFactory factory = new CalculateFactory();
            ICalculate       obj     = factory.GetCalculation(Console.ReadLine());

            //Divide obj = new Divide();
            obj.Calculate(num1, num2);
            Main();
        }
Exemple #14
0
        public ICalculate execute()
        {
            ICalculate calc = null;

            Console.WriteLine("Select the operation 1 - To Add, 2 - To Multiply, 3 - To Divide, 4 - To Subtract");
            int op = Convert.ToInt32(Console.ReadLine());

            switch (op)
            {
            case 1:
                calc = new Add();
                break;

            case 2:
                calc = new Multiply();
                break;

            case 3:
                calc = new Divide();
                break;

            case 4:
                calc = new Subtract();
                break;
            }
            return(calc);
        }
        public ICalculate GetCalculate(string value)
        {
            ICalculate calculate = null;

            switch (value.ToLower())
            {
            case "add":
                calculate = new Add();
                break;

            case "subtract":
                calculate = new Subtract();
                break;

            case "devide":
                calculate = new Devide();
                break;

            default:
                Console.WriteLine("Unknown operation");
                break;
            }

            return(calculate);
        }
Exemple #16
0
 public Colors(System.Action onChange)
 {
     basicAndBlend = new BasicAndBlend();
     // 他のブレンドモードが出てきたらここを変える
     _calculate = new CaluclateMultiple();
     _onChange  = onChange;
 }
        public string RenderTeams(ICalculate myCalculator)
        {
            Utility.Announce("TeamListing " + Heading);
            var r = new SimpleTableReport(Heading, "")
            {
                DoRowNumbers = true
            };

            var ds = LoadTeams(myCalculator);

            //  define the output
            r.AddColumn(new ReportColumn("Name", "NAME", "{0,-15}"));
            r.AddColumn(new ReportColumn("Rating", "RATING", "{0,-10}"));
            r.AddColumn(new ReportColumn("F Avg", "FPAVG", "{0,5:###.0}"));
            r.AddColumn(new ReportColumn("F Points", "POINTS", "{0,5}"));
            r.AddColumn(new ReportColumn("Scores", "SCORES", "{0,9}"));
            r.AddColumn(new ReportColumn("Sacks", "SACKS", "{0,5}"));
            r.AddColumn(new ReportColumn("Ints", "INTERCEPTS", "{0,4}"));
            r.AddColumn(new ReportColumn("Avg YDr allwd", "YDRALLOWED", "{0,5}"));
            r.AddColumn(new ReportColumn("Avg YDp allwd", "YDPALLOWED", "{0,5}"));
            r.AddColumn(new ReportColumn("Points allwd", "ALLOWED", "{0,5}"));

            var dt = ds.Tables[0];

            dt.DefaultView.Sort = "FPAVG DESC";
            r.LoadBody(dt);
            FileOut = string.Format("{0}{1}.htm", Utility.OutputDirectory(), Heading);
            r.RenderAsHtml(FileOut, true);
            return(FileOut);
        }
    private void Awake()
    {
        //calculateMethod1 = GetComponent<ICalculate>();
        calculateMethod1 = new CalculateMultiSumInUpdate();

        //calculateMethod1 = new CalculateWithSequentialJobs();
    }
Exemple #19
0
        public WindowTask(string tagWindowId, string tagWindowName, int windowInterval, int delayWindowCount, ICalculate calc)
        {
            Id               = tagWindowId;
            Name             = tagWindowName;
            WindowInterval   = windowInterval;
            DelayWindowCount = delayWindowCount;

            if (calc == null)
            {
                CalculateOperator = new Avg();
            }
            else
            {
                CalculateOperator = calc;
            }

            _cache = new DataPool();

            _delayCache = new ConcurrentQueue <DataPool>();

            SlidTimeWindow(DateTime.Now);

            _timer           = new System.Timers.Timer(1000);
            _timer.Elapsed  += OnTimedEvent;
            _timer.AutoReset = true;
            _timer.Enabled   = true;
        }
        public string RenderTeamToBeat(ICalculate myCalculator)
        {
#if DEBUG
            Utility.Announce("RenderTeamToBeat " + Heading);
#endif
            var r = new SimpleTableReport(Heading, "")
            {
                DoRowNumbers = true
            };
            //  Crunch the numbers
            var ds = LoadTeamToBeat(myCalculator);
            //  define the output
            r.AddColumn(new ReportColumn("Name", "NAME", "{0,-15}"));
            r.AddColumn(new ReportColumn("Off Rating", "RATING", "{0,-10}"));
            r.AddColumn(new ReportColumn("Opponent", "OPP", "{0,-10}"));
            r.AddColumn(new ReportColumn("FP allwd", "POINTS", "{0,5}"));
            r.AddColumn(new ReportColumn("FP Avg allwd", "FPAVG", "{0,5:###.0}"));
            r.AddColumn(new ReportColumn("Scores allwd", "SCORES", "{0,9}"));
            r.AddColumn(new ReportColumn("Sacks allwd", "SACKS", "{0,5}"));
            r.AddColumn(new ReportColumn("Ints allwd", "INTERCEPTS", "{0,4}"));
            r.AddColumn(new ReportColumn("Avg Pts Scored", "ALLOWED", "{0,5}"));

            var dt = ds.Tables[0];
            dt.DefaultView.Sort = "FPAVG DESC";
            r.LoadBody(dt);
            FileOut = string.Format("{0}{1}.htm", Utility.OutputDirectory(), Heading);
            r.RenderAsHtml(FileOut, true);
            return(FileOut);
        }
Exemple #21
0
        static void Main()
        {
            Console.WriteLine("Write a number");
            var input = Console.ReadLine();

            double num1, num2;
            var    result = Double.TryParse(input, out num1);

            if (!result)
            {
                Console.WriteLine("Error, write a number");
                return;
            }


            Console.WriteLine("Write another number");
            result = Double.TryParse(Console.ReadLine(), out num2);
            if (!result)
            {
                Console.WriteLine("error, write a number");
                return;
            }

            Console.WriteLine("Type +, / or -");
            CalculateFactory calculateFactory = new CalculateFactory();
            ICalculate       obj = calculateFactory.GetCalculation(Console.ReadLine());

            obj.Calculate(num1, num2);
            Main();
        }
Exemple #22
0
        public static ICalculate GetAggCalculate(AggregateCalculateType act)
        {
            ICalculate co = null;

            if (act == AggregateCalculateType.C_Avg)
            {
                co = new Avg();
            }
            else if (act == AggregateCalculateType.C_Sum)
            {
                co = new Sum();
            }
            else if (act == AggregateCalculateType.C_Max)
            {
                co = new Max();
            }
            else if (act == AggregateCalculateType.C_Min)
            {
                co = new Min();
            }

            if (co == null)
            {
                co = new Avg();
            }
            return(co);
        }
Exemple #23
0
        public void IsLinked(Edge sender, Point Begin, Point End)
        {
            Region reg = this.Region.Clone();

            reg.Translate(Location.X, Location.Y);
            if (reg.IsVisible(Begin))
            {
                sender.Link((IVariable)this);
            }
            else if (reg.IsVisible(End))
            {
                if (!VariableList.Contains(sender))
                {
                    VariableList.Add(sender);
                    sender.Link((ICalculate)this);
                }
            }
            else if (VariableList.Contains(sender))
            {
                ICalculate Calculate = ((ICalculate)this);
                Calculate.RemoveVariable(sender);

                sender.Unlink(Calculate);
            }
            else if (!reg.IsVisible(Begin) && sender.Variable == this)
            {
                sender.Unlink((IVariable)this);
            }
        }
Exemple #24
0
 public void SetUp()
 {
     _trackList = new List <Track>();
     //_atmController = Substitute.For<ATMController>(); // er det forkert? - det er ikke interface der bruges
     _calculateTrack = new fakeCalculateTrack();
     _uut            = new AirspaceFilter();
 }
Exemple #25
0
        public void TestMultipleArrayCalculators()
        {
            // 100 Milliion should be good enough
            int arraySize = 100000;
            int arrayNum  = 1000;


            ICalculate[] calcs = new ICalculate[3]
            {
                //new CalculateSumNoJobs(),  // Not Using Jobs is brutally slow
                new CalculateSumWithSequentialPtrJobs(),  // this is currently broken and needs to be fixed
                new CalculateWithSequentialJobs(),
                new CalculateMultiSumInUpdate()
            };


            Dictionary <int, NativeArray <int> > map = CreateMap(arraySize, arrayNum);



            foreach (ICalculate calc in calcs)
            {
                (long elapsed, long result) = ExecutionTimer(calc, map);
                UnityEngine.Debug.Log($"{calc.getDescription()} : ExecutionTime: {elapsed} : result {result}");
            }


            DisposeMap(map);



            // Use the Assert class to test conditions
        }
        public void Setup()
        {
            IConvertInteger ConvertInteger = new ConvertInteger(Integer32ConversionResult);
            ICalculate      AddInteger     = new AddIntegers();

            this.ConvertInteger = ConvertInteger;
            this.AddInteger     = AddInteger;
        }
Exemple #27
0
        static void Main(string[] args)
        {
            ICalculate calc = FactoryMethods.GetCalculateObject(1);
            int        x    = calc.Add(2, 2);

            Console.WriteLine(x);
            Console.ReadKey();
        }
        public void Setup()
        {
            IConvertInteger ConvertInteger  = new ConvertInteger(Integer32ConversionResult);
            ICalculate      SubtractInteger = new SubtractIntegers();

            this.ConvertInteger  = ConvertInteger;
            this.SubtractInteger = SubtractInteger;
        }
Exemple #29
0
 private void Form1_Load(object sender, EventArgs e)  //первое действие для калькулятора и удаление всего
 {
     tmp1            = 0;
     tmp2            = 0;
     Calculate       = null;
     numberBox.Text  = "0";
     numberBox2.Text = "";
 }
 // how to invoke it
 static int Main()
 {
     // invoke it, this is lightning fast and the first-time cache will be arranged
     // also, no need to give the full method anymore, just the classname, as we
     // use an interface for the rest. Almost full type safety!
     ICalculate instanceOfCalculator = this.CreateCachableICalculate("RandomNumber");
     int        result = instanceOfCalculator.ExecuteCalculation();
 }
 // Hesapla
 public int CalculateSummary(Calisan calisan)
 {
     // Çalışan yönetici ise yöneticiye göre hesapla
     if (calisan.isDirector)
     {
         _calculater = new DirectorCalculater();
     }
     // Normal çalışana göre hesapla
     else
     {
         _calculater = new PersonCalculater();
     }
     // Hesaplanan maaşı geri dön
     return _calculater.Calculate(calisan.Sallery);
 }
        public List<Customer> GetRequiredCustomers(ICalculate calc,List<Customer> customers)
        {
            List<Customer> customersAround = new List<Customer> { };
            const double intercomLatitude = 53.3381985;
            const double intercomeLongitude = -6.2592576;
            // loop throught the customers list and return those are within 100km from the Intercom office
            for (int i = 0; i < customers.Count; i++)
            {
                if (calc.Calculate(customers[i].Latitude, customers[i].Longitude, intercomLatitude, intercomeLongitude) < 100 && calc.Calculate(customers[i].Latitude, customers[i].Longitude, intercomLatitude, intercomeLongitude) != 0.0)
                {
                    customersAround.Add(customers[i] as Customer);
                }
            }
            customersAround = customersAround.OrderBy(c => c.ID).ToList(); //order the list by ID

            return customersAround;
        }
Exemple #33
0
 public OffsetVariableExecute(string varName, ICalculate offset)
 {
     this.varName = varName;
     this.offset = offset;
 }
 public LineSeriesTransformer(IFunctionPlotter plotter, ICalculate calculator)
 {
     this.plotter = plotter;
     this.calculator = calculator;
 }
Exemple #35
0
        public void CalculateDefensiveScoring(ICalculate myCalculator, [Optional] bool doOpponent)
        {
            GameList = LoadGamesFrom(myCalculator.StartWeek.Season, myCalculator.StartWeek.Week, myCalculator.Offset);

             PtsFor = 0;
             PtsAgin = 0;
             decimal totFantasyPoints = 0;
             var totDefensiveScores = 0;
             decimal totTotSacks = 0;
             var totTotInterceptions = 0;
             var totGames = 0;
             var totPointsAgin = 0;

             foreach (NFLGame g in GameList)
             {
            #if DEBUG
            Utility.Announce(string.Format("  {0} Opponent in week {1} of {3} is {2}",
               TeamCode, g.Week, g.OpponentTeam(TeamCode).Name, g.Season));
            #endif
            var theTeam = (doOpponent ? g.OpponentTeam(TeamCode) : g.Team(TeamCode));

            myCalculator.Calculate(theTeam, g);

            totFantasyPoints += theTeam.FantasyPoints;
            totDefensiveScores += theTeam.DefensiveScores;
            totTotSacks += theTeam.TotSacks;
            totTotInterceptions += theTeam.TotInterceptions;
            totPointsAgin += theTeam.PtsAgin;
            totGames++;

            #if DEBUG
            if (doOpponent)
               Utility.Announce(
                  string.Format(
                     "    {5} defense against {4} racks up {0,3:##0} Fpts and {1} Defensive Scores {2} Sacks {3} intercepts, scoring {6} points",
                     theTeam.FantasyPoints,
                     theTeam.DefensiveScores,
                     theTeam.TotSacks,
                     theTeam.TotInterceptions,
                     TeamCode,
                     g.OpponentTeam(TeamCode).TeamCode,
                     theTeam.PtsAgin));
            else
               Utility.Announce(
                  string.Format(
                     "    {4} defense against {5} (score {7}) racks up {0,3:##0} Fpts and {1} Defensive Scores {2} Sacks {3} intercepts, allowing {6} points",
                     theTeam.FantasyPoints,
                     theTeam.DefensiveScores,
                     theTeam.TotSacks,
                     theTeam.TotInterceptions,
                     TeamCode,
                     g.OpponentTeam(TeamCode).TeamCode,
                     theTeam.PtsAgin,
                     g.ScoreOut(TeamCode)));
            #endif
             }

             PtsAgin = totPointsAgin;
             FantasyPoints = totFantasyPoints;
             DefensiveScores = totDefensiveScores;
             TotSacks = totTotSacks;
             TotInterceptions = totTotInterceptions;
             Games = totGames;

            #if DEBUG
             if (doOpponent)
            Utility.Announce(
               string.Format(
                  "{0} has allowed defenses to get {1,3:##0} Fpts on {2} Defensive Scores, {3} Sacks and {4} intercepts, scoring {5} points",
                   TeamCode, FantasyPoints, DefensiveScores, TotSacks, TotInterceptions, PtsAgin));
             else
            Utility.Announce(
               string.Format(
                  "{0} defense got {1,3:##0} Fpts on {2} Defensive Scores, {3} Sacks and {4} intercepts, allowing {5} points",
                   TeamCode, FantasyPoints, DefensiveScores, TotSacks, TotInterceptions, PtsAgin));
            #endif
        }
Exemple #36
0
 public MultiplyCalculate(ICalculate[] parts)
 {
     this.parts = parts;
 }
Exemple #37
0
 public NegateCalculate(ICalculate inner)
 {
     this.inner = inner;
 }
Exemple #38
0
 public SubtractCalculate(ICalculate left, ICalculate right)
 {
     this.left = left;
     this.right = right;
 }
Exemple #39
0
 public AddCalculate(ICalculate[] parts)
 {
     this.parts = parts;
 }
Exemple #40
0
 public DivideCalculate(ICalculate left, ICalculate right)
 {
     this.left = left;
     this.right = right;
 }
Exemple #41
0
 public VariableLessThanLogic(string name, ICalculate testVal)
 {
     varName = name;
     testValue = testVal;
 }
Exemple #42
0
        public string RenderTeamToBeat(ICalculate myCalculator)
        {
            #if DEBUG
            Utility.Announce( "RenderTeamToBeat " + Heading );
            #endif
            var r = new SimpleTableReport(Heading, "") {DoRowNumbers = true};
            //  Crunch the numbers
            var ds = LoadTeamToBeat(myCalculator);
            //  define the output
            r.AddColumn(new ReportColumn( "Name", "NAME", "{0,-15}"));
            r.AddColumn(new ReportColumn( "Off Rating", "RATING", "{0,-10}"));
            r.AddColumn(new ReportColumn( "Opponent", "OPP", "{0,-10}" ) );
            r.AddColumn(new ReportColumn( "FP allwd", "POINTS", "{0,5}"));
            r.AddColumn(new ReportColumn( "FP Avg allwd", "FPAVG", "{0,5:###.0}"));
            r.AddColumn(new ReportColumn( "Scores allwd", "SCORES", "{0,9}"));
            r.AddColumn(new ReportColumn( "Sacks allwd", "SACKS", "{0,5}"));
            r.AddColumn(new ReportColumn( "Ints allwd", "INTERCEPTS", "{0,4}"));
            r.AddColumn(new ReportColumn( "Avg Pts Scored", "ALLOWED", "{0,5}"));

            var dt = ds.Tables[0];
            dt.DefaultView.Sort = "FPAVG DESC";
            r.LoadBody(dt);
            FileOut = string.Format("{0}{1}.htm", Utility.OutputDirectory(), Heading);
            r.RenderAsHtml( FileOut, true);
            return FileOut;
        }
Exemple #43
0
        private DataSet LoadTeamToBeat(ICalculate myCalculator)
        {
            var ds = new DataSet();
            var dt = new DataTable();
            var cols = dt.Columns;
            cols.Add("Name", typeof (String));
            cols.Add("Rating", typeof (String));
            cols.Add( "OPP", typeof( String ) );
            cols.Add("Sacks", typeof (Int32));
            cols.Add("Scores", typeof (Int32));
            cols.Add("INTERCEPTS", typeof (Int32));
            cols.Add("Points", typeof (Int32));
            cols.Add("FPAVG", typeof (Decimal));
            cols.Add("Allowed", typeof (Int32));

            foreach (NflTeam t in _teamList)
            {
            #if DEBUG
                //Utility.Announce(string.Format("Doing {0} ", t.NameOut()));
            #endif
                t.FantasyPoints = 0;
                t.DefensiveScores = 0;
                t.TotInterceptions = 0;
                t.TotSacks = 0;

            if (string.IsNullOrEmpty(t.Ratings)) t.SetRecord(myCalculator.StartWeek.Season, skipPostseason: false);
                var dr = dt.NewRow();
                t.CalculateDefensiveScoring( myCalculator, doOpponent: true );
                dr["Name"] = t.Name;
                dr["RATING"] = t.Ratings.Substring(0, 3);
                var g = t.GameFor( myCalculator.StartWeek.Season, myCalculator.StartWeek.WeekNo );
                var opp = "?";
                if ( g == null )
                    opp = "BYE";
                else
                    opp = g.OpponentOut( t.TeamCode );

                dr["OPP"] = opp;
                dr["Scores"] = t.DefensiveScores;
                dr["Sacks"] = t.TotSacks;
                dr["INTERCEPTS"] = t.TotInterceptions;
                dr["Points"] = t.FantasyPoints;
                if (t.Games > 0)
                {
                    dr["Allowed"] = t.PtsAgin / t.Games;
                    dr["FPAVG"] = t.FantasyPoints/t.Games;
                }

                dt.Rows.Add(dr);
                Utility.Announce("---------------------------------------------------------------");
            }
            ds.Tables.Add(dt);
            return ds;
        }
Exemple #44
0
 public SetVariableExecute(string varName, ICalculate newValue)
 {
     this.varName = varName;
     this.newValue = newValue;
 }
Exemple #45
0
        private DataSet LoadTeams(ICalculate myCalculator)
        {
            var ds = new DataSet();
            var dt = new DataTable();
            var cols = dt.Columns;
            cols.Add("Name", typeof (String));
            cols.Add("Rating", typeof (String));
            cols.Add("Sacks", typeof (Int32));
            cols.Add("Scores", typeof (Int32));
            cols.Add("FPAVG", typeof (Decimal));
            cols.Add("INTERCEPTS", typeof (Int32));
            cols.Add("Points", typeof (Int32));
            cols.Add("Allowed", typeof (Int32));
            cols.Add("YDpAllowed", typeof (Int32));
            cols.Add("YDrAllowed", typeof (Int32));

            foreach (NflTeam t in _teamList)
            {
                Utility.Announce(string.Format("Doing {0} ", t.NameOut()));
            if (string.IsNullOrEmpty(t.Ratings)) t.SetRecord(myCalculator.StartWeek.Season, skipPostseason: false);
                var dr = dt.NewRow();
                t.CalculateDefensiveScoring(myCalculator);
                dr["Name"] = t.Name;
                dr["RATING"] = t.Ratings.Substring(3, 3);
                dr["Scores"] = t.DefensiveScores;
                dr["Sacks"] = t.TotSacks;
                dr["INTERCEPTS"] = t.TotInterceptions;
                if (t.Games > 0)
                {
                    dr["YDRALLOWED"] = t.TotYdrAllowed/t.Games;
                    dr["YDPALLOWED"] = t.TotYDpAllowed/t.Games;
                    dr["Allowed"] = t.PtsAgin/t.Games;
                    dr["FPAVG"] = t.FantasyPoints/t.Games;
                }
                dr["Points"] = t.FantasyPoints;
                dt.Rows.Add(dr);
                Utility.Announce("---------------------------------------------------------------");
            }
            ds.Tables.Add(dt);
            return ds;
        }
 public Calculator(ICalculate calculate)
 {
     this.calculate = calculate;
 }
Exemple #47
0
        public string RenderTeams(ICalculate myCalculator)
        {
            Utility.Announce("TeamListing " + Heading);
            var r = new SimpleTableReport(Heading, "") {DoRowNumbers = true};

            var ds = LoadTeams(myCalculator);

            //  define the output
            r.AddColumn(new ReportColumn("Name", "NAME", "{0,-15}"));
            r.AddColumn(new ReportColumn("Rating", "RATING", "{0,-10}"));
            r.AddColumn(new ReportColumn("F Avg", "FPAVG", "{0,5:###.0}"));
            r.AddColumn(new ReportColumn("F Points", "POINTS", "{0,5}"));
            r.AddColumn(new ReportColumn("Scores", "SCORES", "{0,9}"));
            r.AddColumn(new ReportColumn("Sacks", "SACKS", "{0,5}"));
            r.AddColumn(new ReportColumn("Ints", "INTERCEPTS", "{0,4}"));
            r.AddColumn(new ReportColumn("Avg YDr allwd", "YDRALLOWED", "{0,5}"));
            r.AddColumn(new ReportColumn("Avg YDp allwd", "YDPALLOWED", "{0,5}"));
            r.AddColumn(new ReportColumn("Points allwd", "ALLOWED", "{0,5}"));

            var dt = ds.Tables[0];
            dt.DefaultView.Sort = "FPAVG DESC";
            r.LoadBody(dt);
            FileOut = string.Format("{0}{1}.htm", Utility.OutputDirectory(), Heading);
            r.RenderAsHtml( FileOut, true);
            return FileOut;
        }
Exemple #48
0
 public VariableNotEqualLogic(string name, ICalculate testVal)
 {
     varName = name;
     testValue = testVal;
 }
Exemple #49
0
 //Constructor: assigns strategy to interface
 public CalculateClient(ICalculate strategy)
 {
     this.calculateStrategy = strategy;
 }