Beispiel #1
0
        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));
        }
Beispiel #2
0
 public Pen(Tube tube, Cap cap)
 {
     Tube = tube;
     Cap  = cap;
 }