コード例 #1
0
    public static void Main(string[] args)
    {
        int i, bolas = 10;

        Console.WriteLine($"\nBingo de {bolas} bolas\n-----------------------------");
        Bingo b = new Bingo();

        b.Iniciar(bolas);
        for (i = 0; i < bolas; i++)
        {
            Console.WriteLine($"Sorteando ... {b.Proximo()}");
        }

        Console.WriteLine("\nBolas sorteadas\n--------------------");
        foreach (int bola in b.Sorteados())
        {
            Console.WriteLine($"{bola}\t");
        }

        Console.WriteLine($"\nMega Sena\n-----------------------------");
        Mega ms = new Mega();

        for (i = 0; i < 6; i++)
        {
            Console.WriteLine($"Sorteando ... {ms.Proximo()}");
        }

        Console.WriteLine("\nBolas sorteadas\n--------------------");
        foreach (int bola in ms.Sorteados())
        {
            Console.WriteLine($"{bola}\t");
        }

        return;
    }
コード例 #2
0
            public static Bingo Convert(int input)
            {
                var x = input % 5;
                var y = input / 5;

                var result = new Bingo();

                result.Number = x + 1;
                switch (y)
                {
                case 0:
                    result.Letter = 'A';
                    break;

                case 1:
                    result.Letter = 'B';
                    break;

                case 2:
                    result.Letter = 'C';
                    break;

                case 3:
                    result.Letter = 'D';
                    break;

                case 4:
                    result.Letter = 'E';
                    break;
                }

                return(result);
            }
コード例 #3
0
        private async void LoadLink_Click(object sender, RoutedEventArgs e)
        {
            var clipboardPackage = Clipboard.GetContent();

            if (clipboardPackage.Contains(StandardDataFormats.Text))
            {
                string link = await clipboardPackage.GetTextAsync();

                var queries = HttpUtility.ParseQueryString(link);
                if (queries?["board"] != null)
                {
                    Bingo.SetByDataString(queries["board"]);
                    RecentBoards.Insert(0, queries["board"]);
                    return;
                }
            }

            ContentDialog dialog = new ContentDialog
            {
                Title           = "Failed to load board",
                Content         = "Your clipboard does not contain a valid link to a board",
                CloseButtonText = "Ok",
                RequestedTheme  = SettingsManager.GetAppTheme()
            };
            ContentDialogResult result = await dialog.ShowAsync();
        }
コード例 #4
0
    public static void Main(string[] args)
    {
        Bingo b = new Bingo();

        b.Iniciar(10);
        for (int i = 0; i < 10; i++)
        {
            b.Proximo();
        }
        Console.WriteLine("Numeros do bingo:");
        foreach (int q in b.Sorteados())
        {
            Console.WriteLine(q);
        }

        Mega m = new Mega();

        m.Iniciar();
        for (int i = 0; i < 6; i++)
        {
            m.Proximo();
        }
        Console.WriteLine("Numeros da loteria:");
        foreach (int a in m.Sorteados())
        {
            Console.WriteLine(a);
        }
    }
コード例 #5
0
ファイル: BingoTest.cs プロジェクト: brandonmarcum/Casino
        public void T13CheckForNoBingo()
        {
            Bingo bingo = new Bingo(20);

            bingo.CheckForBingo();
            Assert.True(bingo.status == "playing");
        }
コード例 #6
0
        public void ThrowException_WhenTryingToPlayWithInvalidDrawnNumbers(string invalidDrawnNumbers)
        {
            var sut       = Bingo.CreateForBestSolution(SAMPLE_BOARDS);
            var exception = Assert.Throws <ArgumentException>(() => sut.Play(invalidDrawnNumbers));

            Assert.Equal("Invalid drawn numbers", exception.Message);
        }
コード例 #7
0
    public static void Main(string[] args)
    {
        //Criar instância
        Bingo b = new Bingo();

        b.Iniciar(10);

        //'Proximo' sortea um número ainda não sorteado
        for (int i = 0; i < 10; i++)
        {
            //Escrever número sorteado
            Console.WriteLine(b.Proximo());
        }

        //MEGA
        Console.WriteLine("Mega:");

        //Criar instância
        Mega m = new Mega();


        for (int i = 0; i < 10; i++)
        {
            m.Proximo();
        }

        foreach (int i in m.Sorteados())
        {
            Console.WriteLine(i);
        }
    }
コード例 #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            Bingo bingo = dbContext.Bingos.Find(id);

            dbContext.Bingos.Remove(bingo);
            dbContext.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public void SolveSecondPuzzle()
        {
            var sut = Bingo.CreateForWorstSolution(REAL_BOARDS);

            sut.Play(REAL_DRAWN_NUMBERS);

            Assert.Equal(4495, sut.FinalScore);
        }
コード例 #10
0
        public void SolveSecondSample()
        {
            var sut = Bingo.CreateForWorstSolution(SAMPLE_BOARDS);

            sut.Play(SAMPLE_DRAWN_NUMBERS);

            Assert.Equal(1924, sut.FinalScore);
        }
コード例 #11
0
        public void SolveFirstPuzzle()
        {
            var sut = Bingo.CreateForBestSolution(REAL_BOARDS);

            sut.Play(REAL_DRAWN_NUMBERS);

            Assert.Equal(11774, sut.FinalScore);
        }
コード例 #12
0
        public void SolveFirstSample()
        {
            var sut = Bingo.CreateForBestSolution(SAMPLE_BOARDS);

            sut.Play(SAMPLE_DRAWN_NUMBERS);

            Assert.Equal(4512, sut.FinalScore);
        }
コード例 #13
0
        private void TestConvertNumberToIndexInput24ShouldBeArray4and4()
        {
            int[] expectedArray = new int[] { 4, 4 };
            Bingo bingo         = new Bingo(5);

            int[] actualArray = bingo.ConvertNumberToIndex(24);

            Assert.Equal(expectedArray, actualArray);
        }
コード例 #14
0
        private void TestConvertNumberToIndexInput7ShouldBeArray1and2()
        {
            int[] expectedArray = new int[] { 1, 2 };
            Bingo bingo         = new Bingo(5);

            int[] actualArray = bingo.ConvertNumberToIndex(7);

            Assert.Equal(expectedArray, actualArray);
        }
コード例 #15
0
        private void TestConvertNumberToIndexInput0ShouldBeArray0and0()
        {
            int[] expectedArray = new int[] { 0, 0 };
            Bingo bingo         = new Bingo(5);

            int[] actualArray = bingo.ConvertNumberToIndex(0);

            Assert.Equal(expectedArray, actualArray);
        }
コード例 #16
0
 public ActionResult Edit([Bind(Include = "BingoID,RaffleDate,RaffleHour,Status,Description,AwardsID")] Bingo bingo)
 {
     if (ModelState.IsValid)
     {
         dbContext.Entry(bingo).State = EntityState.Modified;
     }
     ViewBag.AwardsID = new SelectList(dbContext.Awards, "AwardsID", "Name", bingo.AwardsID);
     return(View(bingo));
 }
コード例 #17
0
        public void TestNewBoardNoInputShouldBeBingoBoardSize5x5()
        {
            int   expectedBingoBoardSize = 5 * 5;
            Bingo bingo = new Bingo(5);

            bingo.NewBoardGame();
            int actualBingoBoardSize = bingo.GetBoardGame().Length;

            Assert.Equal(expectedBingoBoardSize, actualBingoBoardSize);
        }
コード例 #18
0
ファイル: EnumerableTest.cs プロジェクト: rjmcguire/Theraot
        public void TestCastToImplementedType()
        {
            var ints = new int[] { 42, 12 };
            var strs = new string[] { "foo", "bar" };

            var bingo = new Bingo();

            AssertAreSame(ints, bingo.Cast <int>());
            AssertAreSame(strs, bingo.Cast <string>());
        }
コード例 #19
0
ファイル: BingoTest.cs プロジェクト: brandonmarcum/Casino
        public void T02RollNumber()
        {
            Bingo bingo = new Bingo(20);

            for (int i = 0; i < 2000; i++)
            {
                int x = bingo.RollNumber();
                Assert.True(x >= 1 && x <= 75);
            }
        }
コード例 #20
0
 public ActionResult Edit([Bind(Include = "IdBingo,DataHora,Descricao,Status,DscCancelamenrto,DataCancelamento")] Bingo bingo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bingo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bingo));
 }
コード例 #21
0
ファイル: BingoTest.cs プロジェクト: brandonmarcum/Casino
 public void T14GoldenTest()
 {
     for (int j = 0; j < 500; j++)
     {
         Bingo     bingo = new Bingo(20);
         BingoCard bc    = bingo.bingoCard;
         bingo.CommenceGame();
         Assert.True(bc.card == bingo.bingoCard.card);
         Assert.True(bingo.status == "win" || bingo.status == "lose");
     }
 }
コード例 #22
0
        private async void CompactOverlayButton_Checked(object sender, RoutedEventArgs e)
        {
            var options = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            options.ViewSizePreference = ViewSizePreference.Custom;
            options.CustomSize         = new Size(450, 500);
            bool modeSwitched = await ApplicationView.GetForCurrentView()
                                .TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, options);

            (Window.Current.Content as Frame).Navigate(typeof(LlamaBingo), Bingo.ToDataString());
        }
コード例 #23
0
        private async void LoadLink_Click(object sender, RoutedEventArgs e)
        {
            string link = await Clipboard.GetContent().GetTextAsync();

            var queries = HttpUtility.ParseQueryString(link);

            if (queries?["board"] != null)
            {
                Bingo.SetByDataString(queries["board"]);
                RecentBoards.Insert(0, queries["board"]);
            }
        }
コード例 #24
0
ファイル: BingoTest.cs プロジェクト: brandonmarcum/Casino
        public void T03FillCard()
        {
            Bingo bingo = new Bingo(20);

            for (int r = 0; r < 5; r++)
            {
                for (int c = 0; c < 5; c++)
                {
                    Assert.NotEqual(0, bingo.bingoCard.card[r][c]);
                }
            }
        }
コード例 #25
0
ファイル: BingoTest.cs プロジェクト: brandonmarcum/Casino
        public void T11CheckProperNumbers()
        {
            Bingo bingo = new Bingo(20);

            for (int i = 0; i < 500; i++)
            {
                List <int> x = bingo.bingoCard.FillRow();
                for (int j = 0; j < 5; j++)
                {
                    Assert.True(x[j] >= (j * 15) + 1 && x[j] <= (j + 1) * 15);
                }
            }
        }
コード例 #26
0
ファイル: EnumerableTest.cs プロジェクト: NN---/Theraot
        public void TestCastToImplementedType()
        {
            var ints = new[] { 42, 12 };
            var strs = new[] { "foo", "bar" };

            var bingo = new Bingo();

            // Note: we are testing Cast
            // ReSharper disable once RedundantEnumerableCastCall
            AssertAreSame(ints, bingo.Cast <int>());
            // ReSharper disable once RedundantEnumerableCastCall
            AssertAreSame(strs, bingo.Cast <string>());
        }
コード例 #27
0
        public void RecognizeWinningBoard_WhenLiningVertically()
        {
            const string BOARD = @"14 10 18 22  2
21 16  8 11  0
17 15 23 13 12
24  9 26  6  3
 4 19 20  5  7";

            var sut = Bingo.CreateForBestSolution(BOARD);

            sut.Play("7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1");

            Assert.Equal(4512, sut.FinalScore);
        }
コード例 #28
0
        // GET: Bingoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Bingo bingo = db.Bingo.Find(id);

            if (bingo == null)
            {
                return(HttpNotFound());
            }
            return(View(bingo));
        }
コード例 #29
0
        public void RecognizeWinningBoard_WhenZeroBelongsToSeries()
        {
            const string BOARD = @"14 21 17 24  4
10 16 15  9 19
18  8 23 26 20
22 11 13  6  5
 2  0 12  3  7";

            var sut = Bingo.CreateForBestSolution(BOARD);

            sut.Play("2,0,12,3,7");

            Assert.Equal((14 + 21 + 17 + 24 + 4 + 10 + 16 + 15 + 9 + 19 + 18 + 8 + 23 + 26 + 20 + 22 + 11 + 13 + 6 + 5) * 7, sut.FinalScore);
        }
コード例 #30
0
        private void TestCheckBingoWithIndexDistanceInputStartIndex0IndexDistance1ShouldBeFalse()
        {
            bool  expectedCheckBingo = false;
            Bingo bingo = new Bingo(5);

            bingo.NewBoardGame();
            bingo.MarkNumber(7);
            bingo.MarkNumber(18);
            bingo.MarkNumber(2);

            bool actualCheckBingo = bingo.CheckBingoWithIndexDistance(0, 1);

            Assert.Equal(expectedCheckBingo, actualCheckBingo);
        }