Ejemplo n.º 1
0
        public Match(Nut _nut, Screw _screw)
        {
            Nut   = _nut;
            Screw = _screw;

            if (_nut.Diameter != _screw.Diameter)
            {
                throw new Exception("Error with diameter compare");
            }
            Diameter = _nut.Diameter;
        }
Ejemplo n.º 2
0
        public void Initializer()
        {
            //TODO: INSTANCE THIS BETTER
            Nuts   = new Nut[NutsQuantity];
            Screws = new Screw[ScrewQuantity];

            for (var a = 0; a < NutsQuantity; a++)
            {
                Nuts[a] = new Nut(StaticRandom.Instance.Next(minDiameterSize, maxDiameterSize));
            }

            for (var a = 0; a < ScrewQuantity; a++)
            {
                Screws[a] = new Screw(StaticRandom.Instance.Next(minDiameterSize, maxDiameterSize));
            }
        }
Ejemplo n.º 3
0
        public void Compare()
        {
            if (Nuts.Length == 0 || Screws.Length == 0)
            {
                throw new Exception("Error - Nuts and Screws have to be greater than 0");
            }

            foreach (var screw in Screws)
            {
                Nut NutWithSameDiameter = Nuts.FirstOrDefault(nut => nut.Diameter == screw.Diameter && !nut.Matched);

                if (NutWithSameDiameter != null)
                {
                    NutWithSameDiameter.Matched = screw.Matched = true;

                    var match = new Match(NutWithSameDiameter, screw);

                    matches.Add(match);
                }
            }
        }