public Triangle( ThreeSides threeSides, ITriangleTypeCalculator triangleTypeCalculator) { if (!((threeSides.FirstSide < (threeSides.SecondSide + threeSides.ThirdSide)) && (threeSides.SecondSide < (threeSides.FirstSide + threeSides.ThirdSide)) && (threeSides.ThirdSide < (threeSides.FirstSide + threeSides.SecondSide)))) { //TODO: For me, it should not be a exception, as it is a quick thing to do, but it can be refactored for another approach. throw new InvalidFormatTriangleException("The sides informed form one triangle invalid."); } ThreeSides = threeSides; _triangleTypeCalculator = triangleTypeCalculator; }
public ITriangle Create( ThreeSides threeSides, ITriangleTypeCalculator triangleTypeCalculator) { _triangle = new Triangle(threeSides, triangleTypeCalculator); switch (_triangle.Types) { case TriangleTypes.Equilateral: return(new Equilateral(_triangle)); case TriangleTypes.Scalene: return(new Scalene(_triangle)); case TriangleTypes.Isosceles: return(new Isosceles(_triangle)); default: throw new FormatTriangleNotFindException("Format triangle not yet implemented or find."); } }