Example #1
0
        public void ConsecutiveOnesTest_BackLoad()
        {
            string binary = "001";
            int    result = BinaryCounter.ConsecutiveOnes(binary);

            Assert.AreEqual(1, result);
        }
Example #2
0
        public void ConsecutiveOnesTest_FrontLoad()
        {
            string binary = "1100";
            int    result = BinaryCounter.ConsecutiveOnes(binary);

            Assert.AreEqual(2, result);
        }
Example #3
0
        public void ConsecutiveOnesTest_None()
        {
            string binary = "00";
            int    result = BinaryCounter.ConsecutiveOnes(binary);

            Assert.AreEqual(0, result);
        }
Example #4
0
        public void ConsecutiveOnesTest_End()
        {
            string binary = "10111";
            int    result = BinaryCounter.ConsecutiveOnes(binary);

            Assert.AreEqual(3, result);
        }
Example #5
0
    // Instance of our LightSwitch class
    public LightSwitch()
    {
        button        = new ToggleButton("off", "on");
        counter       = new BinaryCounter(0);
        button.click += counter;
        Panel contentPane = new Panel();

        contentPane.Controls.Add(button);
        contentPane.Controls.Add(counter);
        // TODO: Need to finish implementing this part (help: what is C#'s jFrame?)
    }
Example #6
0
    public LightSwitch()
    {
        button  = new ToggleButton("off", "on");
        counter = new BinaryCounter(0);
        button.addActionListener(counter);
        JPanel contentPane = new JPanel();

        contentPane.add(button);
        contentPane.add(counter);
        JFrame frame = new JFrame("LightSwitch");

        frame.DefaultCloseOperation = JFrame.EXIT_ON_CLOSE;
        frame.ContentPane           = contentPane;
        frame.pack();
        frame.setSize(500, 200);
        frame.Visible = true;
    }
    public LightSwitch()
    {
        Text = "Light Switch";
        Size = new Size(500, 200);

        ToggleButton button = new ToggleButton("off", "on");

        button.Text     = "Off";
        button.Location = new Point(100, 80);

        BinaryCounter counter = new BinaryCounter(0);

        button.Click += new EventHandler(counter.OnButtonClick);


        CenterToScreen();
    }
        private bool GenerateCounter()
        {
            Counter counter = null;

            if (RadiobuttonCounterBinary.IsChecked == true)
            {
                counter = new BinaryCounter();
            }
            if (RadiobuttonCounterGray.IsChecked == true)
            {
                counter = new GrayCounter();
            }
            if (RadiobuttonCounterJohnson.IsChecked == true)
            {
                counter = new JohnsonCounter();
            }
            if (RadiobuttonCounterOneHot.IsChecked == true)
            {
                counter = new Circular1();
            }
            if (RadiobuttonCounterOneZero.IsChecked == true)
            {
                counter = new Circular0();
            }

            counter.IsUpDirection = RadiobuttonCounterUp.IsChecked == true;
            counter.StepCount     = (uint)TextBoxCounterChangeBy.GetIntegerValue();
            counter.CurrentValue  = DataConvertorUtils.ToBitArray(TextBoxCounterStartValue.GetIntegerValue(), (int)genSettings.Size);
            if (counter.CurrentValue == null)
            {
                MessageBox.Show(string.Format("You have errors, when enter StartValue for {0}. It must be one \'0\' and other \'1\'(Circular0) or one \'1\' and other \'0\'(Circular1)", counter.ToString()), "Error!");
                return(false);
            }

            if (timeUnitUserControlClock.TimeInterval.GetTimeUnitInFS() == 0)
            {
                MessageBox.Show("Time must be non zero", "Error!", MessageBoxButton.OK);
                return(false);
            }

            counter.TimeStep = timeUnitUserControlCounter.TimeInterval;

            generator = counter;
            return(true);
        }
Example #9
0
    public LightSwitch()
    {
        Name = "LightSwitch";
        Text = "LightSwitch";
        SuspendLayout();
        button        = new ToggleButton("off", "on");
        counter       = new BinaryCounter(0);
        button.Click += new System.EventHandler(counter.actionPerformed);


        ClientSize = new System.Drawing.Size(500, 200);
        Controls.AddRange(new System.Windows.Forms.Control[]
        {
            button, counter
        });

        ResumeLayout(false);
    }
Example #10
0
        public void ConsecutiveOnesTest_IntConversion10()
        {
            int result = BinaryCounter.ConsecutiveOnes(10);

            Assert.AreEqual(1, result);
        }