コード例 #1
0
        public void Should_ReturnCorrectResult(string input, string expected)
        {
            _streamReader = StreamHelper.GetStream(input);
            var result = new Five().Run(_streamReader);

            Assert.Equal(expected, result);
        }
コード例 #2
0
        public static IRace CreateInstance(RaceType type)
        {
            IRace iRace = null;

            switch (type)
            {
            case RaceType.Human:
                iRace = new Human("123");
                break;

            case RaceType.NE:
                iRace = new NE();
                break;

            case RaceType.ORC:
                iRace = new ORC();
                break;

            case RaceType.Undead:
                iRace = new Undead();
                break;

            case RaceType.Five:
                iRace = new Five();
                break;

            default:
                throw new Exception("wrong RaceType");
            }
            return(iRace);
        }
コード例 #3
0
ファイル: Day8.cs プロジェクト: Tatranskymedved/AdventOfCode
        private void ParseResult(string[] right)
        {
            for (int i = 0; i < right.Length; i++)
            {
                var str = right[i];
                if (str.Length == One.Length && str.All(b => One.Contains(b)))
                {
                    ResultArray[i] = 1;
                }
                if (str.Length == Four.Length && str.All(b => Four.Contains(b)))
                {
                    ResultArray[i] = 4;
                }
                if (str.Length == Seven.Length && str.All(b => Seven.Contains(b)))
                {
                    ResultArray[i] = 7;
                }
                if (str.Length == Eight.Length && str.All(b => Eight.Contains(b)))
                {
                    ResultArray[i] = 8;
                }

                //Part 2
                //6 parts - 0,6,9
                if (str.Length == Zero.Length && str.All(b => Zero.Contains(b)))
                {
                    ResultArray[i] = 0;
                }
                if (str.Length == Six.Length && str.All(b => Six.Contains(b)))
                {
                    ResultArray[i] = 6;
                }
                if (str.Length == Nine.Length && str.All(b => Nine.Contains(b)))
                {
                    ResultArray[i] = 9;
                }

                //5 parts - 2,3,5
                if (str.Length == Two.Length && str.All(b => Two.Contains(b)))
                {
                    ResultArray[i] = 2;
                }
                if (str.Length == Three.Length && str.All(b => Three.Contains(b)))
                {
                    ResultArray[i] = 3;
                }
                if (str.Length == Five.Length && str.All(b => Five.Contains(b)))
                {
                    ResultArray[i] = 5;
                }
            }
            if (ResultArray.Any(a => a < 0))
            {
                throw new Exception();
            }

            //Part 2
            ResultNumber = Convert.ToInt32(ResultArray[0].ToString() + ResultArray[1].ToString() + ResultArray[2].ToString() + ResultArray[3].ToString());
        }
コード例 #4
0
 public static string ToRoman(this int value)
 {
     return(Evaluator.Assert(value)
            .Also((n) => OneThousand.Evaluate(n))
            .Also((n) => FiveHundred.Evaluate(n))
            .Also((n) => OneHundred.Evaluate(n))
            .Also((n) => Fifty.Evaluate(n))
            .Also((n) => Ten.Evaluate(n))
            .Also((n) => Five.Evaluate(n))
            .Also((n) => One.Evaluate(n))
            .Resolve());
 }
コード例 #5
0
 /// <summary>
 /// Use first set of persian characters in unicode ( '\u0660', '\u0661', ... , '\u0669' )
 /// </summary>
 public void UseFirstNumerics()
 {
     Zero.SetData('\u0660');
     One.SetData('\u0661');
     Two.SetData('\u0662');
     Three.SetData('\u0663');
     Four.SetData('\u0664');
     Five.SetData('\u0665');
     Six.SetData('\u0666');
     Seven.SetData('\u0667');
     Eight.SetData('\u0668');
     Nine.SetData('\u0669');
 }
コード例 #6
0
 /// <summary>
 /// Use second set of persian characters in unicode ( '\u06F0', '\u06F1', ... , '\u06F9' )
 /// </summary>
 public void UseSecondNumerics()
 {
     Zero.SetData('\u06F0');
     One.SetData('\u06F1');
     Two.SetData('\u06F2');
     Three.SetData('\u06F3');
     Four.SetData('\u06F4');
     Five.SetData('\u06F5');
     Six.SetData('\u06F6');
     Seven.SetData('\u06F7');
     Eight.SetData('\u06F8');
     Nine.SetData('\u06F9');
 }
コード例 #7
0
ファイル: Numbers.cs プロジェクト: FKartaeusch/LEDMatrixAPI
 public TryOutNumbers(Color color)
 {
     zero  = new Zero(color);
     one   = new One(color);
     two   = new Two(color);
     three = new Three(color);
     four  = new Four(color);
     five  = new Five(color);
     six   = new Six(color);
     seven = new Seven(color);
     eight = new Eight(color);
     nine  = new Nine(color);
 }
コード例 #8
0
        private void Calculate_Click(object sender, RoutedEventArgs e)
        {
            var IsValidatePrice       = Double.TryParse(InputPrice.Text, out var price);
            var IsValidateCustomerPay = Double.TryParse(InputCustomerPay.Text, out var customerPay);
            var change = sut.ComputeChange(price, customerPay);
            var result = sut.GetChangeBankNotesAndCoins(change);

            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Thousand, out var Thousand);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.FiveHundreds, out var FiveHundred);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Hundred, out var Hundred);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Fifty, out var Fifty);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Twenty, out var Twenty);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Ten, out var Ten);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Five, out var Five);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.One, out var One);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.TwentyFifth, out var TwentyFiveStang);
            result.BankNotesAndCoins.TryGetValue(BankNotesAndCoinsInSatang.Fiftieth, out var FiftyStang);
            if (IsValidatePrice && IsValidateCustomerPay && price >= 0 && customerPay >= 0 && customerPay >= price)
            {
                MoneyChangeResult.Text    = result.RoundedChange.ToString();
                countThousand.Text        = Thousand.ToString();
                countFiveHundred.Text     = FiveHundred.ToString();
                countHundred.Text         = Hundred.ToString();
                countFifty.Text           = Fifty.ToString();
                countTwenty.Text          = Twenty.ToString();
                countTen.Text             = Ten.ToString();
                countFive.Text            = Five.ToString();
                countOne.Text             = One.ToString();
                countTwentyFiveStang.Text = TwentyFiveStang.ToString();
                countFiftyStang.Text      = FiftyStang.ToString();
                StatusChange.Text         = "จ่ายเงินเรียบร้อย";
            }
            else
            {
                MoneyChangeResult.Text    = "";
                countThousand.Text        = "";
                countFiveHundred.Text     = "";
                countHundred.Text         = "";
                countFifty.Text           = "";
                countTwenty.Text          = "";
                countTen.Text             = "";
                countFive.Text            = "";
                countOne.Text             = "";
                countTwentyFiveStang.Text = "";
                countFiftyStang.Text      = "";
                StatusChange.Text         = "";
                StatusChange.Text         = "กรอกจำนวนเงินไม่ถูกต้อง";
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: T1M0UT/Study
 public List <int> GetList(List <int> answer)
 {
     One?.GetList(answer);
     answer.Add(value);
     Two?.GetList(answer);
     Three?.GetList(answer);
     Four?.GetList(answer);
     Five?.GetList(answer);
     Six?.GetList(answer);
     Seven?.GetList(answer);
     Eight?.GetList(answer);
     Nine?.GetList(answer);
     O?.GetList(answer);
     return(answer);
 }
コード例 #10
0
ファイル: Combination.cs プロジェクト: satirikasha/MatchThree
        public static bool Detect(out Combination combination, Cell input)
        {
            combination = new Combination();
            if (!input.IsNotNullOrEmpty())
            {
                return(false);
            }
            combination.Cells  = new Cell[0];
            combination.Center = input;
            combination.Type   = input.ChildItem.Type;

            if (Three.IsCombination(ref combination))
            {
                var three = combination as Three;
                combination = three;
                if (Four.IsCombination(ref three))
                {
                    var four = three as Four;
                    combination = four;
                    if (Five.IsCombination(ref four))
                    {
                        var five = four as Five;
                        combination = five;
                    }
                }
                three = combination as Three;
                if (combination.GetType() != typeof(Five) && Angle.IsCombination(ref three))
                {
                    var angle = three as Angle;
                    combination = angle;
                }
            }

            var resultName = combination.GetType().Name;

            if (resultName != "Combination")
            {
                Debug.Log(resultName);
            }

            var result = combination.GetType() != typeof(Combination);

            if (!result)
            {
                combination = null;
            }
            return(result);
        }
コード例 #11
0
        public static void Run()
        {
            var one = new One();

            Assert.True(one.Test);

            var two = new Two <object>();

            Assert.True(two.Test);

            var three = new Three();

            Assert.False(three.Test); // => interceptors of base class are private!

            var four = new Four();

            Assert.True(four.Test);

            {
                var five = new Five <string>();

                var strValue = five.StringProp;
                five.StringProp = "asd";

                var intValue = five.IntProp;
                five.IntProp = 123;

                var genericValue = five.GenericProp;
                five.GenericProp = "123";
            }

            {
                var five = new Five <int>();

                var strValue = five.StringProp;
                five.StringProp = "asd";

                var intValue = five.IntProp;
                five.IntProp = 123;

                var genericValue = five.GenericProp;
                five.GenericProp = 123;
            }
        }
コード例 #12
0
        public static void Dispose()
        {
            GrassTexture.Dispose();
            WaterTexture.Dispose();
            ForestTexture.Dispose();
            HouseTexture.Dispose();
            MountainTexture.Dispose();
            Building.Dispose();

            Zero.Dispose();
            One.Dispose();
            Two.Dispose();
            Three.Dispose();
            Five.Dispose();
            Six.Dispose();
            Eight.Dispose();
            Nine.Dispose();

            Turbine.Dispose();
        }
コード例 #13
0
ファイル: NumberUtils.cs プロジェクト: 0k1/WPF-Clock
        public static float[,] getControlPointsFor(int start)
        {
            switch (start)
            {
            case (-1):
                return(Null.getInstance().getControlPoints());

            case 0:
                return(Zero.getInstance().getControlPoints());

            case 1:
                return(One.getInstance().getControlPoints());

            case 2:
                return(Two.getInstance().getControlPoints());

            case 3:
                return(Three.getInstance().getControlPoints());

            case 4:
                return(Four.getInstance().getControlPoints());

            case 5:
                return(Five.getInstance().getControlPoints());

            case 6:
                return(Six.getInstance().getControlPoints());

            case 7:
                return(Seven.getInstance().getControlPoints());

            case 8:
                return(Eight.getInstance().getControlPoints());

            case 9:
                return(Nine.getInstance().getControlPoints());

            default:
                throw new ArgumentException("Unsupported number requested");
            }
        }
コード例 #14
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public RoulettePlayer() : base()
        {
            // Cash/bets.
            _totalCash = Constants.InitialCashDollars;

            // Chips.
            _selectedChip           = ChipType.Undefined;
            OneChip                 = new One();
            FiveChip                = new Five();
            TwentyFiveChip          = new TwentyFive();
            OneHundredChip          = new OneHundred();
            FiveHundredChip         = new FiveHundred();
            OneThousandChip         = new OneThousand();
            FiveThousandChip        = new FiveThousand();
            TwentyFiveThousandChip  = new TwentyFiveThousand();
            OneHundredThousandChip  = new OneHundredThousand();
            FiveHundredThousandChip = new FiveHundredThousand();

            // Commands.
            ClearBetsCommand = new DelegateCommand(ClearBets).ObservesCanExecute(() => PlaceBets);
        }
コード例 #15
0
ファイル: URI1018.cs プロジェクト: robson-cambr/URI
        static void Uri1018(string[] args)
        {
            int N;
            int Change;
            int Hundred, Fifty, Twenty, Ten, Five, Two, One;

            N = int.Parse(Console.ReadLine());

            Change = N;

            Hundred = Change / 100;
            Change  = Change - (Hundred * 100);

            Fifty  = Change / 50;
            Change = Change - (Fifty * 50);

            Twenty = Change / 20;
            Change = Change - (Twenty * 20);

            Ten    = Change / 10;
            Change = Change - (Ten * 10);

            Five   = Change / 5;
            Change = Change - (Five * 5);

            Two    = Change / 2;
            Change = Change - (Two * 2);

            One    = Change / 1;
            Change = Change - (One * 1);

            Console.WriteLine(N.ToString());
            Console.WriteLine(Hundred.ToString() + " nota (s) de R$ 100,00");
            Console.WriteLine(Fifty.ToString() + " nota (s) de R$ 50,00");
            Console.WriteLine(Twenty.ToString() + " nota (s) de R$ 20,00");
            Console.WriteLine(Ten.ToString() + " nota (s) de R$ 10,00");
            Console.WriteLine(Five.ToString() + " nota (s) de R$ 5,00");
            Console.WriteLine(Two.ToString() + " nota (s) de R$ 2,00");
            Console.WriteLine(One.ToString() + " nota (s) de R$ 1,00");
        }
コード例 #16
0
        /// <summary>
        /// Gives me money.
        /// </summary>
        /// <param name="money">The money.</param>
        public static void GiveMeMoney(int money)
        {
            // Setup entities
            Cash hundred = new Hundred();
            Cash fifty   = new Fifty();
            Cash twenty  = new Twenty();
            Cash ten     = new Ten();
            Cash five    = new Five();

            // Setup Chain of Responsibility
            hundred.SetSuccessor(fifty);
            fifty.SetSuccessor(twenty);
            twenty.SetSuccessor(ten);
            ten.SetSuccessor(five);

            // Generate and process ATM requests
            int moneyInBank = 1000;
            var bank        = new Bank(moneyInBank / 100, moneyInBank / 50, moneyInBank / 20, moneyInBank / 10, moneyInBank / 5);

            // hundred.ProcessRequest(money, bank);

            // Testing multiple requests
            for (int i = 1; i < 150; i++)
            {
                // Request #i
                Console.WriteLine("Request #{0}\n", i);
                Console.WriteLine("Amount requested: {0}€", money);
                Console.WriteLine("Amount available: {0}€\n", bank.GetTotal());
                hundred.ProcessRequest(money, bank);
                Console.WriteLine("\nEnd Of Request #{0}\n-----------------\n", i);

                var randomNumber = new Random().Next(5, 200);
                money = ((int)(randomNumber / 5)) * 5;
            }

            // Wait for user
            Console.ReadKey();
        }
コード例 #17
0
        /// <summary>
        /// The PlaceBet method is called to place a bet for the current selected chip.
        /// </summary>
        public void PlaceBet()
        {
            try
            {
                if (PlaceBets && SelectedChip != ChipType.Undefined)
                {
                    BetAmount = BetAmount + Chip.GetChipValue(SelectedChip);

                    // Create a chip at the bet location.
                    Chip chip = null;
                    switch (Bet.SelectedChip)
                    {
                    case ChipType.One:
                        chip = new One(Chips.Count());
                        break;

                    case ChipType.Five:
                        chip = new Five(Chips.Count());
                        break;

                    case ChipType.TwentyFive:
                        chip = new TwentyFive(Chips.Count());
                        break;

                    case ChipType.OneHundred:
                        chip = new OneHundred(Chips.Count());
                        break;

                    case ChipType.FiveHundred:
                        chip = new FiveHundred(Chips.Count());
                        break;

                    case ChipType.OneThousand:
                        chip = new OneThousand(Chips.Count());
                        break;

                    case ChipType.FiveThousand:
                        chip = new FiveThousand(Chips.Count());
                        break;

                    case ChipType.TwentyFiveThousand:
                        chip = new TwentyFiveThousand(Chips.Count());
                        break;

                    case ChipType.OneHundredThousand:
                        chip = new OneHundredThousand(Chips.Count());
                        break;

                    case ChipType.FiveHundredThousand:
                        chip = new FiveHundredThousand(Chips.Count());
                        break;
                    }

                    if (chip != null)
                    {
                        OnBetPlaced?.Invoke(chip.Value);    // Notify that the bet has been placed.
                        Chips.Add(chip);                    // Add the chip to the bet.
                        CombineChips();                     // Combine the chips.
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Bet.PlaceBet(object parameter): " + ex.ToString());
            }
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: elkku26/Chip26
        public void Advance()
        {
            //advance the program by one cycle


            //check if reached end of memory;
            if (pc >= 4095)
            {
                Debug.WriteLine("ERR: reached end of memory");
            }
            else if (currentInstruction == "0000")
            {
                Debug.WriteLine("ERR: empty opcode");
            }


            //parse current instruction and set it to a variable
            currentInstruction = String.Format("{0:X2}", memory[pc]) + String.Format("{0:X2}", memory[pc + 1]);
            byteInstruction    = memory[pc];
            Debug.WriteLine("Instruction as byte: " + byteInstruction);

            //parse x
            x = Convert.ToInt16(Convert.ToString(currentInstruction[1]), 16);

            //parsy y
            y = Convert.ToInt16(Convert.ToString(currentInstruction[2]), 16);

            //parse n
            n = Convert.ToInt16(Convert.ToString(currentInstruction[3]), 16);

            //parse kk
            kk = Convert.ToInt16(currentInstruction.Substring(2), 16);

            //parse nnn
            nnn = Convert.ToInt16(currentInstruction.Substring(1), 16);


            Debug.WriteLine($"\npc={pc}");
            Debug.WriteLine($"The current instruction is:{currentInstruction} ");



            //set drawflag to false by default
            drawFlag = false;

            //switch for all possible instructions
            //TODO: replace this
            switch (currentInstruction)
            {
            case "00E0":
                Debug.WriteLine("00E0");

                if (!usedInstructions.Contains("00E0"))
                {
                    usedInstructions.Add("00E0");
                }

                Instructions.clr(this);
                return;


            case "00EE":

                Debug.WriteLine("00EE");

                if (!usedInstructions.Contains("00EE"))
                {
                    usedInstructions.Add("00EE");
                }


                Instructions.ret(this);
                return;


            case var dummy when One_addr.IsMatch(dummy):
                Debug.WriteLine("1nnn");

                if (!usedInstructions.Contains("1nnn"))
                {
                    usedInstructions.Add("1nnn");
                }


                Instructions.jmp(this);

                return;


            case var dummy when Two_addr.IsMatch(dummy):
                Debug.WriteLine("2nnn");

                if (!usedInstructions.Contains("2nnn"))
                {
                    usedInstructions.Add("2nnn");
                }

                Instructions.call(this);

                return;


            case var dummy when Three.IsMatch(dummy):
                Debug.WriteLine("3xkk");

                if (!usedInstructions.Contains("3xkk"))
                {
                    usedInstructions.Add("3xkk");
                }


                Instructions.skp_if_kk(this);

                return;


            case var dummy when Four.IsMatch(dummy):
                Debug.WriteLine("4xkk");

                if (!usedInstructions.Contains("4xkk"))
                {
                    usedInstructions.Add("4xkk");
                }


                Instructions.skp_not_kk(this);

                return;


            case var dummy when Five.IsMatch(dummy):
                Debug.WriteLine("5xy0");

                if (!usedInstructions.Contains("5xy0"))
                {
                    usedInstructions.Add("5xy0");
                }


                Instructions.skp_if_x_y(this);

                return;


            case var dummy when Six.IsMatch(dummy):
                Debug.WriteLine("6xkk");

                if (!usedInstructions.Contains("6xkk"))
                {
                    usedInstructions.Add("6xkk");
                }


                Instructions.ld_vx_kk(this);

                return;


            case var dummy when Seven.IsMatch(dummy):
                Debug.WriteLine("7xkk");

                if (!usedInstructions.Contains("7xkk"))
                {
                    usedInstructions.Add("7xkk");
                }


                Instructions.add_vx_kk(this);

                return;


            case var dummy when Eight_load.IsMatch(dummy):
                Debug.WriteLine("8xy0");

                if (!usedInstructions.Contains("8xy0"))
                {
                    usedInstructions.Add("8xy0");
                }


                Instructions.ld_vx_vy(this);

                return;


            case var dummy when Eight_or.IsMatch(dummy):
                Debug.WriteLine("8xy1");

                if (!usedInstructions.Contains("8xy1"))
                {
                    usedInstructions.Add("8xy1");
                }



                Instructions.or_vx_vy(this);

                return;


            case var dummy when Eight_and.IsMatch(dummy):
                Debug.WriteLine("8xy2");

                if (!usedInstructions.Contains("8xy2"))
                {
                    usedInstructions.Add("8xy2");
                }



                Instructions.and_vx_vy(this);

                return;


            case var dummy when Eight_xor.IsMatch(dummy):
                Debug.WriteLine("8xy3");

                if (!usedInstructions.Contains("8xy3"))
                {
                    usedInstructions.Add("8xy3");
                }



                Instructions.xor_vx_vy(this);

                return;


            case var dummy when Eight_add.IsMatch(dummy):
                Debug.WriteLine("8xy4");

                if (!usedInstructions.Contains("8xy4"))
                {
                    usedInstructions.Add("8xy4");
                }



                Instructions.add_vx_vy(this);

                return;


            case var dummy when Eight_sub.IsMatch(dummy):
                Debug.WriteLine("8xy5");

                if (!usedInstructions.Contains("8xy5"))
                {
                    usedInstructions.Add("8xy5");
                }



                Instructions.sub_vx_vy(this);

                return;


            case var dummy when Eight_shr.IsMatch(dummy):
                Debug.WriteLine("8xy6");


                if (!usedInstructions.Contains("8xy6"))
                {
                    usedInstructions.Add("8xy6");
                }



                Instructions.shr_vx_vy(this);

                return;


            case var dummy when Eight_subn.IsMatch(dummy):
                Debug.WriteLine("8xy7");

                Instructions.subn_vy_vx(this);

                return;


            case var dummy when Eight_shl.IsMatch(dummy):
                Debug.WriteLine("8xyE");

                if (!usedInstructions.Contains("8xyE"))
                {
                    usedInstructions.Add("8xyE");
                }



                Instructions.shl_vx_vy(this);

                return;


            case var dummy when Nine.IsMatch(dummy):
                Debug.WriteLine("9xy0");

                if (!usedInstructions.Contains("9xy0"))
                {
                    usedInstructions.Add("9xy0");
                }



                Instructions.skp_not_equal(this);

                return;


            case var dummy when A_addr.IsMatch(dummy):

                if (!usedInstructions.Contains("Annn"))
                {
                    usedInstructions.Add("Annn");
                }

                Debug.WriteLine($"Annn where nnn = {currentInstruction.Substring(1, 3)}");
                Instructions.ld_i_nnn(this);

                return;


            case var dummy when B_addr.IsMatch(dummy):
                Debug.WriteLine("Bnnn");

                if (!usedInstructions.Contains("Bnnn"))
                {
                    usedInstructions.Add("Bnnn");
                }


                Instructions.jmp_v0_nnn(this);

                return;


            case var dummy when C_addr.IsMatch(dummy):
                Debug.WriteLine("Cxkk");

                if (!usedInstructions.Contains("Cxkk"))
                {
                    usedInstructions.Add("Cxkk");
                }


                Instructions.ld_vx_rand(this);

                return;


                #region draw_func

            //huomionarvoista:
            // optimoinnin vuoksi voisi olla fiksua keksiä tapa vähentää type conversioneita
            // huom. mahdolliset bugit jotka mainittu edellisissä kommenteissa

            case var dummy when D_addr.IsMatch(dummy):

                stopwatch.Start();

                Debug.WriteLine("Dxyn");

                if (!usedInstructions.Contains("Dxyn"))
                {
                    usedInstructions.Add("Dxyn");
                }


                Instructions.drw(this);

                stopwatch.Stop();
                Debug.WriteLine($"draw function elapsed ms = {stopwatch.ElapsedMilliseconds}");
                stopwatch.Reset();


                break;
                #endregion

            case var dummy when E_skp.IsMatch(dummy):
                Debug.WriteLine("Ex9E");

                if (!usedInstructions.Contains("Ex9E"))
                {
                    usedInstructions.Add("Ex9E");
                }


                Instructions.skp_vx(this);

                return;


            case var dummy when E_sknp.IsMatch(dummy):
                Debug.WriteLine("ExA1");

                if (!usedInstructions.Contains("ExA1"))
                {
                    usedInstructions.Add("ExA1");
                }



                Instructions.sknp_vx(this);

                return;


            case var dummy when F_load_from_dt.IsMatch(dummy):
                Debug.WriteLine("Fx07");

                if (!usedInstructions.Contains("Fx07"))
                {
                    usedInstructions.Add("Fx07");
                }


                Instructions.ld_vx_dt(this);

                Debug.WriteLine($"registers[{x}] = {registers[x]}");

                return;


            case var dummy when F_load_key.IsMatch(dummy):
                Debug.WriteLine("Fx0A");

                if (!usedInstructions.Contains("Fx0A"))
                {
                    usedInstructions.Add("Fx0");
                }


                Instructions.ld_vx_key(this);

                return;


            case var dummy when F_load_to_dt.IsMatch(dummy):
                Debug.WriteLine("Fx15");

                if (!usedInstructions.Contains("Fx15"))
                {
                    usedInstructions.Add("Fx15");
                }


                Instructions.ld_dt_vx(this);

                Debug.WriteLine($"delayTimer has been set to {delayTimer}");

                return;


            case var dummy when F_load_to_st.IsMatch(dummy):
                Debug.WriteLine("Fx18");

                if (!usedInstructions.Contains("Annn"))
                {
                    usedInstructions.Add("Annn");
                }


                Instructions.ld_st_vx(this);

                return;

            case var dummy when Add_i_vx.IsMatch(dummy):
                Debug.WriteLine("Fx1E");

                if (!usedInstructions.Contains("Fx1E"))
                {
                    usedInstructions.Add("Fx1E");
                }


                Instructions.add_i_vx(this);

                return;


            case var dummy when Load_f_vx.IsMatch(dummy):
                Debug.WriteLine("Fx29");

                if (!usedInstructions.Contains("Fx29"))
                {
                    usedInstructions.Add("Fx29");
                }


                Instructions.ld_f_vx(this);

                return;


            case var dummy when Load_b_vx.IsMatch(dummy):
                Debug.WriteLine("Fx33");

                if (!usedInstructions.Contains("Fx33"))
                {
                    usedInstructions.Add("Fx33");
                }


                Instructions.ld_bcd(this);

                return;

            case var dummy when Load_i_vx.IsMatch(dummy):
                Debug.WriteLine("Fx55");

                if (!usedInstructions.Contains("Fx55"))
                {
                    usedInstructions.Add("Fx55");
                }


                Instructions.ld_i_vx(this);

                return;

            case var dummy when Load_vx_i.IsMatch(dummy):
                Debug.WriteLine("Fx65");

                if (!usedInstructions.Contains("Fx65"))
                {
                    usedInstructions.Add("Fx65");
                }



                Instructions.ld_vx_i(this);

                return;


            default:
                Debug.WriteLine("Unknown instruction");
                pc += 2;
                return;
            }
        }
コード例 #19
0
        void ReleaseDesignerOutlets()
        {
            if (Clear != null)
            {
                Clear.Dispose();
                Clear = null;
            }

            if (Decimal != null)
            {
                Decimal.Dispose();
                Decimal = null;
            }

            if (Divise != null)
            {
                Divise.Dispose();
                Divise = null;
            }

            if (Eight != null)
            {
                Eight.Dispose();
                Eight = null;
            }

            if (Equals != null)
            {
                Equals.Dispose();
                Equals = null;
            }

            if (Five != null)
            {
                Five.Dispose();
                Five = null;
            }

            if (Four != null)
            {
                Four.Dispose();
                Four = null;
            }

            if (Minus != null)
            {
                Minus.Dispose();
                Minus = null;
            }

            if (Multiply != null)
            {
                Multiply.Dispose();
                Multiply = null;
            }

            if (Nine != null)
            {
                Nine.Dispose();
                Nine = null;
            }

            if (One != null)
            {
                One.Dispose();
                One = null;
            }

            if (Plus != null)
            {
                Plus.Dispose();
                Plus = null;
            }

            if (ResultField != null)
            {
                ResultField.Dispose();
                ResultField = null;
            }

            if (Seven != null)
            {
                Seven.Dispose();
                Seven = null;
            }

            if (Six != null)
            {
                Six.Dispose();
                Six = null;
            }

            if (Three != null)
            {
                Three.Dispose();
                Three = null;
            }

            if (ToggleSign != null)
            {
                ToggleSign.Dispose();
                ToggleSign = null;
            }

            if (Two != null)
            {
                Two.Dispose();
                Two = null;
            }

            if (Zero != null)
            {
                Zero.Dispose();
                Zero = null;
            }
        }
コード例 #20
0
        public IRace CreateInstance()
        {
            IRace race = new Five();

            return(race);
        }
コード例 #21
0
        /*Functionality Added to make the calculator work with Keyboard NumberPad
         * When the correct Key is detected it will fire off the corresponding button press*/
        private void Window_KeyDownPreview(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.NumPad0:
                Zero.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad1:
                One.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad2:
                Two.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad3:
                Three.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad4:
                Four.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad5:
                Five.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad6:
                Six.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad7:
                Seven.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad8:
                Eight.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.NumPad9:
                Nine.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.Add:
                Plus.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.Subtract:
                Minus.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.Multiply:
                Multiply.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.Divide:
                Divide.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;

            case Key.Enter:
                Equals.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                break;
            }
        }
コード例 #22
0
        public void FiveCodeTest()
        {
            Five five = new Five();

            Assert.AreEqual(five.Code, "$5");
        }
コード例 #23
0
        //OFF


        /*************************************************************
        *  Obsługa przycisków
        *************************************************************/
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.D1 || e.Key == Key.NumPad1)
            {
                One.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D2 || e.Key == Key.NumPad2)
            {
                Two.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D3 || e.Key == Key.NumPad3)
            {
                Three.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D4 || e.Key == Key.NumPad4)
            {
                Four.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D5 || e.Key == Key.NumPad5)
            {
                Five.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D6 || e.Key == Key.NumPad6)
            {
                Six.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D7 || e.Key == Key.NumPad7)
            {
                Seven.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D8 || e.Key == Key.NumPad8)
            {
                if (Keyboard.IsKeyDown(Key.LeftShift))
                {
                    Star.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                }
                else
                {
                    Eight.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                }
            }
            else if (e.Key == Key.D9 || e.Key == Key.NumPad9)
            {
                Nine.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.D0 || e.Key == Key.NumPad0)
            {
                Zero.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }

            /**********************************************************/

            /*else if (e.Key == Key.Enter)
             * {
             *  Equals.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
             * }*/
            else if (e.Key == Key.OemComma || e.Key == Key.OemPeriod || e.Key == Key.Decimal)
            {
                Dot.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.OemMinus || e.Key == Key.Subtract)
            {
                Minus.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.OemPlus || e.Key == Key.Add)
            {
                Plus.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.Delete)
            {
                AC.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.Back)
            {
                C.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.Divide || e.Key == Key.OemBackslash || e.Key == Key.OemQuestion || e.Key == Key.Oem5)
            {
                Slash.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.Multiply)
            {
                Star.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.P)
            {
                MP.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            }
            else if (e.Key == Key.Escape)
            {
                Application.Current.Shutdown();
            }
            Console.WriteLine(e.Key.ToString());
        }