Ejemplo n.º 1
0
        /// <summary>
        /// this function calculates intensity factor by accepting NP, IF and FTP
        /// </summary>
        /// <returns>returns intensity factor of a string data type</returns>
        public string CalculateIntensityFactor()
        {
            double IF1 = NP / FTP;

            IF = Math.Round(IF1, 2);

            return(IF.ToString());
        }
Ejemplo n.º 2
0
        private void Calculate_Click(object sender, EventArgs e)
        {
            //Declare Swimmer's Label, so we can write the Swimmer's Name, and store it with his/her proper Data

            string swimmerName;

            swimmerName = Console.ReadLine();

            swimmerName = lblSwimerName.ToString();

            //Declarations

            double longDistance;
            double longTime;
            double shortDistance;
            double shortTime;

            double workoutDistance;
            double workingTime;

            double CSS; //Critical Swim Speed
            double NSS; //Normalized Swim Speed
            double IF;  //Intensity Factor
            double TSS; //Training Stress Score

            //Inputs
            //This 4 lines (with code) are used to calculate the CSS
            longDistance = double.Parse(lblLongerDistance.Text);
            longTime     = double.Parse(lblLongerTime.Text);

            shortDistance = double.Parse(lblShorterDistance.Text);
            shortTime     = double.Parse(lblShorterTime.Text);

            //This 2 lines of code are used to calculate the NSS
            workoutDistance = double.Parse(lblWorkoutDistance.Text);
            workingTime     = double.Parse(lblWorkingTime.Text);

            //Processing

            CSS = (longDistance - shortDistance) / (longTime - shortTime); //Calculates the CSS
            NSS = (workoutDistance / workingTime);                         //Calculates tge NSS
            IF  = (NSS / CSS);                                             //Calculates the IF
            TSS = ((Math.Pow(IF, 3)) * (workingTime / 3600) * 100);        //Calculates the TSS

            //OutPut

            lblCSS.Text = CSS.ToString();
            lblNSS.Text = NSS.ToString();
            lblIF.Text  = IF.ToString();
            lblTSS.Text = TSS.ToString();
        }
Ejemplo n.º 3
0
        // An expression starts out with a starting value, which we get from GetNextValue
        // Functions are applied to that starting value
        // Each function has a "tier", which means how many tokens can go after it
        // toks: the max amount of tokens that should be parsed (determined by tier)
        private Expression ParseExpression(bool topLevel = false, int toks = -1)
        {
            var val = GetNextValue(ref toks);

            while (!tokenizer.EOF() && toks != 0 && tokenizer.Peek().Type == TokenType.Function)
            {
                // Another token has been consumed; therefore we need to update the breaks
                var next = tokenizer.Next().Value;
                toks--;

                if (Function.IsUnary(next))
                {
                    val = new FunctionInvocationExpression(val, next);
                }
                else
                {
                    var tier = Function.GetTier(next);
                    var arg  = ParseExpression(false, tier);
                    val = new FunctionInvocationExpression(val, next, arg);
                }
                // Get rid of all the brackets if this expression is a top level one
                // And also clear out all the breaks
                if (topLevel)
                {
                    bracket = -1;
                    while (IsBracket())
                    {
                        tokenizer.Next();
                    }
                }
                else
                {
                    ProcessBrackets();
                }
            }
            //If a '?' follows this expression, it means it's a conditional expression
            if (!tokenizer.EOF() && tokenizer.Peek().Type == TokenType.Punctuation && tokenizer.Peek().Value == IF.ToString())
            {
                tokenizer.Next();
                val = new ConditionalExpression(val, ParseExpression(), ParseExpression());
            }
            return(val);
        }