public void Install(string material, double length) { var tube = _factory.Create(material, length); if (tube.Length == length) { Console.WriteLine($"installato tubo di {material} con lunghezza {length}"); } else { throw new InvalidOperationException(); } }
public Pen Create(double length, double radius) { tube = _tubeFactory.Create(length, radius); cap = _capFactory.Create(radius); double lengthDelta = Math.Abs(tube.Length - length); double radiusDelta = Math.Abs(tube.Radius - cap.Radius) / radius; if (lengthDelta / length > 0.01) { throw new Exception($"Tube length delta {lengthDelta} exceed 1.0%"); } if (radiusDelta > 0.005) { throw new Exception($"Radius tube delta {radiusDelta} exceed 0.5%"); } return(new Pen(tube, cap)); }