示例#1
0
 public void SetBike(RingSet frontRings, RingSet rearRings)
 {
     _frontShifter = new Shifter {
         Rings = frontRings
     };
     _rearShifter = new Shifter {
         Rings = rearRings
     };
     _gearBox          = new GearBox(_frontShifter.Rings, _rearShifter.Rings);
     _frontShiftBiased = false;
 }
示例#2
0
        static void Main(string[] args)
        {
            char input = '_';

            RingSet chainring = new RingSet {
                Rings = new int[] {}
            };
            RingSet cassette = new RingSet {
                Rings = new int[] {}
            };

            Bike myBike = new Bike();

            while (input != 'x')
            {
                PrintMainMenu();
                input = char.ToLower(Console.ReadKey().KeyChar);

                switch (input)
                {
                case 'n':
                    Console.WriteLine("\nCreating new bike");
                    chainring.Rings = new int[] { 32, 22 };
                    cassette.Rings  = new int[] { 11, 13, 15, 17, 19, 21, 24, 28, 32, 37, 46 };
                    myBike.SetBike(chainring, cassette);
                    PrintGearCombinations(myBike.GetGearBox());
                    break;

                case 'g':
                    Console.WriteLine("\nGetting current bike");
                    Console.WriteLine($"Current bike has {myBike.GetShifterRingCounts("front")} chainring(s)");
                    Console.WriteLine($"Front shifter is current at {myBike.GetShifter("front").CurPos+1} chainring");
                    Console.WriteLine($"Current bike has {myBike.GetShifterRingCounts("rear")} ring(s)");
                    Console.WriteLine($"Rear shifter is current at {myBike.GetShifter("rear").CurPos+1} ring");
                    PrintGearCombinations(myBike.GetGearBox());
                    break;

                default:
                    Console.WriteLine($"\nUnknown input char: {input}");
                    break;
                }
            }
        }
示例#3
0
        public void SetGearBox(RingSet frontRings, RingSet rearRings)
        {
            Dictionary <double, List <int[]> > newGearBox = new Dictionary <double, List <int[]> >();
            List <int[]> combination = new List <int[]>();

            int debugGearCount = 0;

            for (int frontRingPos = 0; frontRingPos < frontRings.RingCount; frontRingPos++)
            {
                for (int rearRingPos = 0; rearRingPos < rearRings.RingCount; rearRingPos++)
                {
                    double ratio          = Math.Round((double)rearRings.Rings[rearRingPos] / frontRings.Rings[frontRingPos], 2);
                    int[]  newCombination = { frontRingPos, rearRingPos };

                    if (newGearBox.ContainsKey(ratio))
                    {
                        newGearBox[ratio].Add(newCombination);
                    }
                    else
                    {
                        List <int[]> newCombinations = new List <int[]> {
                            newCombination
                        };
                        newGearBox.Add(ratio, newCombinations);
                        debugGearCount++;
                    }
                }
            }

            _gearBox = new IGearRatio[newGearBox.Count];

            int curGear = 0;

            foreach (KeyValuePair <double, List <int[]> > gear in newGearBox)
            {
                _gearBox[curGear] = new GearRatio(gear.Key, gear.Value);
                curGear++;
            }
        }
示例#4
0
        public void SetShifterRings(string shifterType, RingSet rings)
        {
            if (rings.RingCount <= 0)
            {
                Console.WriteLine("***ERROR*** TRYING TO SETUP FRONT SHIFTER WITH EMPTY GEARS");
            }

            switch (shifterType.ToLower())
            {
            case "front":
                _frontShifter.SettingGears(rings);
                break;

            case "rear":
                _rearShifter.SettingGears(rings);
                break;

            default:
                Console.WriteLine($"***ERROR*** TRYING TO SETUP UNKNOWN SHIFTER TYPE {shifterType}");
                break;
            }
            _gearBox.SetGearBox(_frontShifter.Rings, _rearShifter.Rings);
        }
示例#5
0
 public void SettingGears(RingSet ringSet)
 {
     _curPos = 0;
     _rings  = ringSet;
 }
示例#6
0
 public GearBox(RingSet frontRings, RingSet rearRings)
 {
     SetGearBox(frontRings, rearRings);
 }