×

Loading...

可以用 github copilot 产生 c#

public struct Problem { }
public struct Solution { }
public class Skill
{
    public Solution? Solve(Problem problem) 
    { throw new NotImplementedException();  }
}

// define a class to represent an engineer. Each engineer could have multiple skills.
public class Engineer
{
    public string Name { get; set; }
    public List<Skill> Skills { get; set; }
}

// define a class to represent a team. Each team could have multiple engineers.
public class Team
{
    public string Name { get; set; }
    public List<Engineer> Engineers { get; set; }
    public Solution? Solve(Problem problem)
    {
        foreach (var engineer in Engineers)
        foreach (var skill in engineer.Skills)
        {
            var solution = skill.Solve(problem);
            if (solution != null) return solution;
        }

        return null;
    }
}
Report

Replies, comments and Discussions: