Sha256: ccd359c2299d7dba83cb5e44eb6f67daf9b41e4c28bd8a1be010e55a9dbc8037

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

using System.Collections;
using Generators.Input;
using Generators.Output;
namespace Generators.Exercises
{
    public class Triangle : GeneratorExercise
    {
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var data in canonicalData.Cases)
            {
                if (data.Property == "equilateral")
                    data.Property = "IsEquilateral";
                else if (data.Property == "isosceles")
                    data.Property = "IsIsosceles";
                else if (data.Property == "scalene")
                    data.Property = "IsScalene";

                data.Input["sides"] = SplitArrayToValues(data.Input["sides"]);
                data.SetInputParameters("sides");
                data.UseFullDescriptionPath = true;

            }
        }

        private UnescapedValue SplitArrayToValues(IEnumerable input)
        {
            const string template = "{% for item in {{input}} %}{{item}}{% if forloop.last == false %}, {% endif %}{% endfor %}";

            return new UnescapedValue(TemplateRenderer.RenderInline(template, new { input }));
        }
    }
}

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.179 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.178 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.177 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.176 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.175 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.174 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.173 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.172 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.171 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.170 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.169 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.167 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.166 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.165 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.164 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.163 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.162 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.161 tracks/csharp/generators/Exercises/Triangle.cs
trackler-2.2.1.160 tracks/csharp/generators/Exercises/Triangle.cs