Exemple #1
0
        public override void Execute()
        {
            double length             = 1.0;
            double wristCircumference = 1.0;

            ConsoleKey gender = AssignmentHelper.RequestKey(
                "Wat is je geslacht?",
                new[] { ConsoleKey.M, ConsoleKey.F }
                );

            AssignmentHelper.RequestInput(this, "Hoe lang ben je? (in cm)", out double height);

            int ideal = 0;

            if (gender == ConsoleKey.M)
            {
                ideal = Convert.ToInt32(height - 100);
            }
            else if (gender == ConsoleKey.F)
            {
                AssignmentHelper.RequestInput(this, "Wat is je pols omtrek? (in cm)", out double circumference);
                ideal = Convert.ToInt32((length + 4.0 * wristCircumference - 100) / 2);
            }
            else
            {
                Error = "Onbekend geslacht...";
            }

            Output.Add("");
            Output.Add($"Je ideale gewicht is {ideal} kg");
        }
        public async Task <ResponseCommon> CreateAssignment(Assignment assignment)
        {
            /*//Sample data to pass from swagger
             * {
             * "title":"test","description":"test",
             * "industry_id":"1",
             * "pricing_type":"flat",
             * "location_offsite":"false",
             * "location_name":"asdasdsad",
             * "location_number":"100",
             * "location_address1":"add1",
             * "location_address2":"add2",
             * "location_city":"pune",
             * "location_state":"mh",
             * "location_zip":"411048",
             * "location_country":"india",
             * "scheduled_start_date":"2020/04/07 10:10 PM",
             * "scheduled_end_date":"2020/04/08 12:10 PM",
             * "pricing_flat_price":"100",
             * "template_id":"5285380806"
             * }
             */
            if (assignment == null)
            {
                //for testing purpose
                assignment = new Assignment();
            }

            return(await AssignmentHelper.CreateAssignment(assignment));

            //return new HttpResponseMessage(HttpStatusCode.OK);
        }
        public override void Execute()
        {
            IDictionary <string, string> dictionary = new Dictionary <string, string>
            {
                { "nl", "Tot ziens!" },
                { "fr", "Au revoir!" },
                { "frl", "Oant sjens!" },
                { "en", "Bye!" },
                { "de", "Tschuess" }
            };

            Output.Add("In welke taal moet het woordje `tot ziens` worden weer gegeven?");
            Output.Add("De opties zijn: Nederlands(NL), Engels(EN), Fries(FRL) en Frans(FR)");

            AssignmentHelper.RequestInput(this, "Typ de twee of driecijferige code in", out string language);

            string result = "";

            if (dictionary.TryGetValue(language.ToLower(), out result))
            {
                Output.Add($"Tot ziens in {language.ToUpper()} is {result}");
            }
            else
            {
                Output.Add("Onbekende taal :(");
            }
        }
Exemple #4
0
        public override void Execute()
        {
            AssignmentHelper.RequestInput(
                this,
                "Hoeveel leerlingen wil je toevoegen?",
                out int students
                );

            string[] studentNames = new string[students];

            for (int i = 0; i < students; i++)
            {
                AssignmentHelper.RequestInput(
                    this,
                    "Wat is de naam van de leerling?",
                    out string studentName
                    );

                studentNames[i] = studentName;
            }

            string names = String.Join(", ", studentNames);

            Output.Add($"In totaal hebben we {students} leerlingen met de namen: {names}");
        }
 public Mayor(Game game) : base(game, CellState.Mayor, MOVING_SPEED,
                                new Point(START_X, START_Z),
                                ResourcesHUD.START_POPULATION, STEP_TIME)
 {
     this.mayorMenu      = null;
     this.WindmillExists = false;
     this.BankExists     = false;
     this.MarketExists   = false;
     this.BarracksExists = false;
     AssignmentHelper.FillList(this.OnRecallBuildersEvent, this.OnAddBuildersEvent, this.OnRecallLumberjacksEvent, this.OnAddLumberjacksEvent,
                               this.OnRecallMinersEvent, this.OnAddMinersEvent, this.OnRecallFarmersEvent, this.OnAddFarmersEvent,
                               this.OnRecallBankersEvent, this.OnAddBankersEvent, this.OnRecallSellersEvent, this.OnAddSellersEvent);
     TrainingMenuHelper.FillList(this.OnAddSwordmenEvent, this.OnAddArchersEvent, this.OnAddBatteringRamEvent);
     this.resourcesHUD     = game.Components.OfType <ResourcesHUD>().ElementAt(0);
     this.calculatePayment = new Dictionary <PrivilegesCosts, Int16[]>()
     {
         { PrivilegesCosts.CommonWorker, new Int16[4] {
               0, 0, 0, 1
           } },                                                         //{stone, wood, gold, food}
         { PrivilegesCosts.PrivilegedWorker, new Int16[4] {
               0, 0, 1, 4
           } },
         { PrivilegesCosts.Soldier, new Int16[4] {
               5, 1, 5, 5
           } }
     };
 }
        public override void Execute()
        {
            Output.Add("De invoer moet gescheiden zijn met een comma.");
            ShowOutput();

            AssignmentHelper.RequestInput(
                this,
                "Voer de getallen in die je wilt gebruiken.",
                out string input
                );

            string[] split  = input.Split(',');
            int[]    values = Array.ConvertAll(split, int.Parse);

            AssignmentHelper.RequestInput(
                this,
                $"Welke index wil je opvragen? (van 0 tot {values.Length - 1})",
                out int index
                );

            if (index < 0)
            {
                Error = "Kan index lager als 0 niet opvragen.";
                return;
            }

            if (index > values.Length)
            {
                Error = "Kan index niet opvragen.";
                return;
            }

            Output.Add($"De waarde van index {index} is {values[index]}");
        }
Exemple #7
0
        /// <summary>
        /// Builds the statements that generate the value of this expression
        /// </summary>
        /// <param name="block">Block to which to add the statements</param>
        /// <param name="expr">Expression to build</param>
        /// <param name="operand1">First operand</param>
        /// <param name="operand2">second operand</param>
        /// <returns></returns>
        public static Declaration BuildStatements(Block block, Expression expr, Token operand1, Token operand2)
        {
            Token opToken = expr.Tokens[0];

            var            decl          = block.CreateTempDeclaration(TypeHelper.GetType(block, operand1));
            ValueStatement initialAssign = AssignmentHelper.ParseSingle(block, decl, operand1);

            block.Statements.Add(initialAssign);

            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            foreach (var type in asm.GetTypes())
            {
                if (type.BaseType == typeof(MathStatement))
                {
                    try
                    {
                        IMathOperator mathOp = (IMathOperator)asm.CreateInstance(type.FullName);
                        if (opToken.Equals(mathOp.GetHandledOperator()))
                        {
                            MathStatement mathStatement;
                            Datum         datum = Datum.Parse(block, operand2);
                            if (datum == null)
                            {
                                MessageSystem.Instance.ThrowNewError(MessageSystem.ErrorCode.UndeclaredVar);
                                return(null);
                            }

                            if (decl.Type.IndirectionLevels > 0)
                            {
                                Type derefType = decl.Type.Clone() as Type;
                                derefType.Dereference();

                                var offsetDecl = block.CreateTempDeclaration(new BuiltInType("int"));
                                block.Statements.Add(AssignmentHelper.ParseSingle(block, offsetDecl, operand2));
                                var  imm  = new Immediate(new Token(derefType.Size.ToString()));
                                Mult mult = new Mult(offsetDecl, imm);
                                block.Statements.Add(mult);
                                datum = offsetDecl;
                            }

                            mathStatement = Activator.CreateInstance(type,
                                                                     new object[] { decl, datum }) as MathStatement;
                            block.Statements.Add(mathStatement);
                            break;
                        }
                    }
                    catch (MissingMethodException) { }
                }
            }

            return(decl);
        }
Exemple #8
0
        public override void Execute()
        {
            const double DollarRate = 1.2231;

            AssignmentHelper.RequestInput(this, "Hoeveel euro wil je omzetten naar USD?", out string input);

            if (double.TryParse(input, NumberStyles.Number, CultureInfo.InvariantCulture, out double euros))
            {
                double usdConverted = euros * DollarRate;
                Output.Add("");
                Output.Add($"{euros} EUR is gelijk aan {usdConverted} USD");
            }
        }
Exemple #9
0
        /// <summary>
        /// Rule implementation.
        /// </summary>
        /// <param name="context">Rule context.</param>
        protected override void Execute(RuleContext context)
        {
            var target = (IEftvFromChange)context.Target;

            DateTime?from         = target.EftvFrom;
            DateTime?fromOriginal = target.EftvFromOriginal;

            if (AssignmentHelper.AssignNullableValue(ref from, fromOriginal))
            {
                if (target.IsNew == false)
                {
                    string message = FromToDate.FromDateFrozen;
                    context.Results.Add(new RuleResult(RuleName, PrimaryProperty, message)
                    {
                        Severity = Severity
                    });
                }
            }
        }
        public override void Execute()
        {
            AssignmentHelper.RequestInput(this, "Wat is je voornaam?", out string name);
            AssignmentHelper.RequestInput(this, "Wat is je achternaam?", out string lastName);
            AssignmentHelper.RequestInput(this, "In welke straat woon je?", out string street);
            AssignmentHelper.RequestInput(this, "Wat is je huisnummer?", out string houseNumber);
            AssignmentHelper.RequestInput(this, "Wat is je postcode?", out string postalCode);
            AssignmentHelper.RequestInput(this, "In welke stad of dorp woon je?", out string city);

            Output.Add("");
            Output.Add("Output:");
            Output.Add("");

            Output.Add("===================================================");
            Output.Add(string.Format("| {0,-22} | {1,-22} |", name, lastName));
            Output.Add(string.Format("| {0,-22} | {1,-22} |", street, houseNumber));
            Output.Add(string.Format("| {0,-22} | {1,-22} |", postalCode, city));
            Output.Add("===================================================");
        }
Exemple #11
0
        public override void Execute()
        {
            Output.Add("Voer de getallen in waarvan je de grootste getal wil selecteren.");
            Output.Add("Zorg er voor dat de getallen gescheiden zijn met een comma");

            AssignmentHelper.RequestInput(this, "Voer de getallen in waarvan je de grootste getal wil selecteren.", out string input);
            string[] split = input.Split(',');

            int[] values = Array.ConvertAll(split, int.Parse);

            int highestValue = 0;

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] > highestValue)
                {
                    highestValue = values[i];
                }
            }

            Output.Add("");
            Output.Add($"De hoogste waarde is {highestValue}");
        }
Exemple #12
0
        public override void Execute()
        {
            Output.Add("Voer de getallen in waarbij alleen de oneven getallen geprint worden.");
            Output.Add("Zorg er voor dat de getallen gescheiden zijn met een comma");
            ShowOutput();

            AssignmentHelper.RequestInput(
                this,
                "Voer de getallen in:",
                out string numbers
                );

            string[] split  = numbers.Split(',');
            int[]    values = Array.ConvertAll(split, int.Parse);

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] % 2 == 0)
                {
                    Output.Add($"{values[i]} is een even getal");
                }
            }
        }
Exemple #13
0
        public override void Execute()
        {
            int[] values = new int[3];

            for (int i = 0; i < 3; i++)
            {
                AssignmentHelper.RequestInput(
                    this,
                    "Voer een getal in",
                    out int number
                    );

                values[i] = number;
            }

            int sum = 0;

            for (int i = 0; i < values.Length; i++)
            {
                sum += values[i];
            }

            Output.Add($"De som van de waarden is {sum}");
        }
Exemple #14
0
        public override void Execute()
        {
            bool  exit        = false;
            float totalDriven = 0.0f;
            float fuelUsed    = 0.0f;

            while (true)
            {
                AssignmentHelper.RequestInput(
                    this,
                    "Hoeveel kilometer heeft u gereden sinds laatste tankbeurt?",
                    out float km
                    );

                AssignmentHelper.RequestInput(
                    this,
                    "Hoeveel liter heeft u getankt?",
                    out float fuel
                    );

                totalDriven += km;
                fuelUsed    += fuel;

                if (fuel == 0)
                {
                    break;
                }
            }

            Output.Add("");
            Output.Add($"Je hebt {totalDriven} km gereden en {fuelUsed} liter brandstof verbruikt.");

            float fuelConsumption = (float)Math.Round(100 / (totalDriven / fuelUsed), 2);

            Output.Add($"Brandstof verbruik is {fuelConsumption} liter per 100 km.");
        }
Exemple #15
0
        public override void Execute()
        {
            bool   calculateWindChill = false;
            double windSpeed          = 0.0;

            //Tell the user which options are available.
            Output.Add("--------------------------------------------------------------");
            Output.Add("Temperatuur types: F (Farhenheit), C (Celsius), K (Kelvin).");
            Output.Add("Zet de letter achter het nummer, hoofdletters maakt niet uit.");
            Output.Add("--------------------------------------------------------------");

            //Ask the user which value he wants to use for the conversion
            AssignmentHelper.RequestInput(
                this,
                "Voer de temperatuur in die je wilt gebruiken. (bijv. 20.0C of 25.6F)",
                out string inputString
                );

            bool parsed = TemperatureParser.Parse(inputString, out TemperatureUnit inputUnit, out double inputValue);

            if (!parsed)
            {
                Error = $"Kan waarde `{inputString}` niet conventeren naar een double.";
                return;
            }

            if (inputUnit == TemperatureUnit.Unknown)
            {
                Error = $"Onbekende temperatuur type!";
                return;
            }

            // Ask the user which type he wants to convert to.
            bool targetUnitSuccess = AssignmentHelper.RequestInput(
                this,
                "Naar welk temperatuur type wil je het conveteren (F/C/K)?",
                out char targeUnitResult
                );

            if (!targetUnitSuccess)
            {
                Error = "Kan input niet converteren naar goede type.";
                return;
            }

            TemperatureUnit targetUnit = (TemperatureUnit)targeUnitResult;

            if (inputUnit.Equals(targetUnit))
            {
                Error = $"De conversie is het zelfde (van {inputUnit} naar {targetUnit})";
                return;
            }

            ConsoleKey key = AssignmentHelper.RequestKey(
                "Wil je ook het gevoelstemperatuur berekenen?",
                new[] { ConsoleKey.Y, ConsoleKey.N }
                );

            if (key == ConsoleKey.Y)
            {
                AssignmentHelper.RequestInput <double>(
                    this,
                    "Wat is de wind snelheid in kilometer per seconde?",
                    out windSpeed
                    );

                calculateWindChill = true;
            }
            else if (key == ConsoleKey.N)
            {
                calculateWindChill = false;
            }
            else
            {
                Error = "De ingevoerde toets is incorrect.";
                return;
            }

            //Lookup conversion, print result
            double result        = TemperatureConverter.Convert(inputValue, inputUnit, targetUnit);
            double resultRounded = Math.Round(result, 2);

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("");
            builder.AppendLine($"Het gegeven temperatuur was {inputValue} {inputUnit}, omgezet is het resultaat: {result} {targetUnit}");
            builder.AppendLine("");

            //Append the results of the wind chill calculations.
            if (calculateWindChill)
            {
                double resultWindChill        = TemperatureConverter.ConvertInclWindChill(inputValue, windSpeed, inputUnit, targetUnit);
                double resultWindChillRounded = Math.Round(resultWindChill, 2);

                builder.AppendLine($"Het gevoelstemperatuur met een windsnelheid van {windSpeed} km/h is {resultWindChillRounded} {targetUnit} \n");
            }

            //Write out the entire result.
            Output.Add(builder.ToString());
            Output.Add("Oant moan!");
        }
        public override void Execute()
        {
            AssignmentHelper.RequestInput(this, "Hoe oud ben je?", out int age);
            AssignmentHelper.RequestInput(this, "Met hoeveel mensen ben je?", out int size);

            ConsoleKey ladiesNight = AssignmentHelper.RequestKey(
                "Is het vanavond Ladies night?",
                new[] { ConsoleKey.Y, ConsoleKey.N }
                );


            //Check if it's ladies night.
            if (ladiesNight == ConsoleKey.Y)
            {
                ConsoleKey married = AssignmentHelper.RequestKey(
                    "Ben je gehuwd?",
                    new[] { ConsoleKey.Y, ConsoleKey.N }
                    );

                if (married == ConsoleKey.Y)
                {
                    Output.Add("Je moet ongehuwd zijn om mee te doen aan de ladies night.");
                    return;
                }

                if (married == ConsoleKey.N)
                {
                    if (age < 30)
                    {
                        Output.Add($"Je bent {age} jaar oud, je hebt toegang tot de club.");
                    }
                    else
                    {
                        Output.Add($"Je bent te oud. :(");
                        return;
                    }
                }
            }

            // Normal routine check.
            if (age < 16)
            {
                Output.Add("Je moet minimaal 16 jaar oud zijn.");
                return;
            }
            else
            {
                Output.Add($"Je bent {age} jaar oud, veel plezier!");
            }

            if (age >= 21)
            {
                Output.Add($"Omdat je 21 jaar of ouder bent, krijg je ook VIP toegang.");
            }

            int discount = 0;

            switch (size)
            {
            case 0:
            case 1:
            case 2:
                discount = 0;
                break;

            case 3:
                discount = 10;
                break;

            case 4:
                discount = 20;
                break;

            case 5:
                discount = 50;
                break;

            default:
                discount = 100;
                break;
            }

            string discountStr = "";

            if (discount == 0)
            {
                discountStr += "geen korting.";
            }
            else if (discount == 100)
            {
                discountStr += "gratis toegang.";
            }
            else
            {
                discountStr += +discount + "% korting.";
            }


            Output.Add($"Een groep met {size} mensen krijgt {discountStr}");
        }
        public override void Execute()
        {
            int    multiplier = 0;
            int    sixCounter = 0;
            Random rnd        = new Random();

            while (true)
            {
                AssignmentHelper.RequestInput(
                    this,
                    "Hoeveel euro wil je inzetten?",
                    out int bet
                    );

                if (bet > 100)
                {
                    Error = "Inzet is te hoog, maximaal 100 EUR!";
                    return;
                }

                if (bet < 5)
                {
                    Error = "Inzet is te laag, minimaal 5 EUR!";
                    return;
                }

                for (int i = 0; i < 3; i++)
                {
                    Output.Add("Druk een toets om the dobbelen...");
                    ShowOutput();

                    Console.ReadKey();

                    int roll1 = rnd.Next(1, 7);
                    int roll2 = rnd.Next(1, 7);

                    Output.Add("");
                    Output.Add($"Je gooit dobbelsteen 1 en gooit {roll1}");
                    Output.Add($"Je gooit dobbelsteen 2 en gooit {roll2}");
                    Output.Add("");

                    if (roll1 == 6 && roll2 == 6)
                    {
                        multiplier += 50;
                        Output.Add("Je hebt dubbel zessen, je inzet is x50!");
                    }

                    if (roll1 == roll2)
                    {
                        multiplier += 10;
                        Output.Add("Je hebt twee de zelfde getallen, je inzet is x10!");
                    }

                    if (roll1 == 6)
                    {
                        sixCounter++;
                    }
                    if (roll2 == 6)
                    {
                        sixCounter++;
                    }
                }

                Output.Add("");

                if (sixCounter >= 2)
                {
                    Output.Add("Je hebt bij de 3 worpen 2 of meer zessen gegooid. Je inzet is x2!");
                    multiplier += 2;
                }

                int w = bet * multiplier;
                if (w == 0)
                {
                    Output.Add("Helaas je hebt niks gewonnen!");
                }
                else
                {
                    Output.Add($"Je hebt {w} euro gewonnen!");
                }

                ShowOutput();

                ConsoleKey key = AssignmentHelper.RequestKey(
                    "Wil je nog een keer spelen?",
                    new[] { ConsoleKey.Y, ConsoleKey.N }
                    );


                if (key == ConsoleKey.N)
                {
                    break;
                }
                else if (key == ConsoleKey.Y)
                {
                    bet        = 0;
                    multiplier = 0;
                }
                else
                {
                    Error = "Onbekende toets...";
                    return;
                }
            }
        }
Exemple #18
0
 private static bool isDifferent(DateTime?newEftvTo, DateTime?originalEftvTo)
 {
     return(AssignmentHelper.AssignNullableValue(ref originalEftvTo, newEftvTo));
 }