Exemple #1
0
        public void Check(Tube t)
        {
            if (t.Status == TubeStatus.Rejected)
            {
                return;
            }

            if (!isValid(t))
            {
                t.Status = TubeStatus.Rejected;
            }
        }
Exemple #2
0
        public Tube Create(double projectLength, double projectWeight, string type)
        {
            Tube t = null;

            switch (type)
            {
            case "CastIron": t = new CastIronTube(); break;

            case "Pvc": t = new PvcTube(); break;

            case "Steel": t = new SteelTube(); break;

            default: throw new ArgumentException("Not recognized tube type!");
            }

            t.ProjectLength = projectLength;
            t.ProjectWeight = projectWeight;

            t.RealLength = t.ProjectLength * (1 + ((_r.NextDouble() - 0.5) / 25));
            t.RealWeight = t.ProjectWeight * (1 + ((_r.NextDouble() - 0.5) / 10));

            return(t);
        }
Exemple #3
0
 public void Approve(Tube t)
 {
     t.Status = TubeStatus.Ready;
 }
Exemple #4
0
 protected override bool isValid(Tube t)
 {
     return(Math.Abs(t.RealWeight - t.ProjectWeight) / 100 < 0.03);
 }
Exemple #5
0
 protected override bool isValid(Tube t)
 {
     return(Math.Abs(t.RealLength - t.ProjectLength) / 100 < 0.01);
 }
Exemple #6
0
 protected abstract bool isValid(Tube t);