コード例 #1
0
    static void Main()
    {
        Console.SetWindowSize(80, 25);
        Console.SetBufferSize(80, 25);
        Aquarium aq = new Aquarium();

        ClownFish c = new ClownFish();

        c.X = 15; c.Y = 16;

        Trout t = new Trout();

        t.X = 5; t.Y = 6;

        Shark s = new Shark();

        s.X = 60; s.Y = 22;

        Rock r1 = new Rock();

        r1.X = 10; r1.Y = 24;

        Rock r2 = new Rock();

        r2.X = 40; r2.Y = 24;

        Coral co = new Coral();

        co.X = 18; co.Y = 19;

        do
        {
            System.Console.Clear();
            c.Swim();
            t.Swim();
            s.Swim();
            c.Display();
            t.Display();
            s.Display();
            co.Display();
            r1.Display();
            r2.Display();
            System.Threading.Thread.Sleep(200);
        } while (true);
    }
コード例 #2
0
        public async Task If_user_isnt_specified_with_command_say_error_message(string messageWithNoUser)
        {
            // arrange
            var expectedMessage  = $"You must specify a user to trout.";
            var twitchLibMessage = TwitchLibMessageBuilder.Create()
                                   .WithUsername("doesn't matter")
                                   .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage(messageWithNoUser)
                              .Build();

            var troutRequest = new Trout(chatMessage);

            // act
            await _handler.Handle(troutRequest, CancellationToken.None);

            // assert
            _mockTwitchClient.Verify(m =>
                                     m.SendMessage(It.IsAny <string>(), expectedMessage, false), Times.Once);
        }
コード例 #3
0
        private void BtnFishCombo_Click(object sender, RoutedEventArgs e)
        {//declair variables
            int Trout;

            int.TryParse(txtTrout.Text, out Trout);
            int Pike;

            int.TryParse(txtPike.Text, out Pike);
            int Pickerel;

            int.TryParse(txtPickerel.Text, out Pickerel);
            int Limit;

            int.TryParse(txtLimit.Text, out Limit);
            int Total;
            int TroutValue;
            int PikeValue;
            int PickerelValue;

            TroutValue    = Trout * 5;
            PikeValue     = Pike * 2;
            PickerelValue = Pickerel * 7;
            //Multiply number of fish given from input by the fishes value



            if (TroutValue + PikeValue + PickerelValue <= Limit)
            {
                lblTrout.Content   = Trout.ToString() + " Trout";
                lblPike.Content    = Pike.ToString() + " Pike";
                lblPikerel.Content = Pickerel.ToString() + " Pickerel";
            }
            else
            {
                lblOutput.Content = "too many fish";
            }
        }
コード例 #4
0
        public async Task If_user_exists_then_perform_trout_action_with_target_username(string userThatDoesExist)
        {
            // arrange
            var twitchLibMessage = TwitchLibMessageBuilder.Create()
                                   .WithUsername("doesn't matter")
                                   .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage($"!trout {userThatDoesExist}")
                              .Build();

            _mockTwitchWrapper.Setup(m => m.DoesUserExist(It.IsAny <string>()))
            .ReturnsAsync(true);

            var troutRequest = new Trout(chatMessage);

            // act
            await _handler.Handle(troutRequest, CancellationToken.None);

            // assert
            _mockTwitchClient.Verify(x =>
                                     x.SendMessage(It.IsAny <string>(), $"/me slaps @{userThatDoesExist.Replace("@","")} around a bit with a large trout.", It.IsAny <bool>())
                                     , Times.Once);
        }
コード例 #5
0
        public async Task If_user_doesnt_exist_trouting_say_error_message(string userThatDoesntExist)
        {
            // arrange
            var expectedMessage  = $"User {userThatDoesntExist.Replace("@", "")} doesn't exist.";
            var twitchLibMessage = TwitchLibMessageBuilder.Create()
                                   .WithUsername("doesn't matter")
                                   .Build();
            var chatMessage = ChatMessageBuilder.Create()
                              .WithTwitchLibMessage(twitchLibMessage)
                              .WithMessage($"!trout {userThatDoesntExist}")
                              .Build();

            _mockTwitchWrapper.Setup(m => m.DoesUserExist(userThatDoesntExist))
            .ReturnsAsync(false);

            var troutRequest = new Trout(chatMessage);

            // act
            await _handler.Handle(troutRequest, CancellationToken.None);

            // assert
            _mockTwitchClient.Verify(m =>
                                     m.SendMessage(It.IsAny <string>(), expectedMessage, false), Times.Once);
        }
コード例 #6
0
        public static void NoClientMain()
        {
            #region Old Code...
            ////Animal Object Declaration
            ////old way of non-abstract class
            ////Animal myAnimal = new Animal();
            ////Mammal Object Declaration
            ////Mammal myMammal = new Mammal();
            ////Primate Object Declaration
            ////Primate myPrimate = new Primate();
            ////Human Object Declaration
            //Human myHuman = new Human();
            ////Bird Object Declaration
            ////Bird myBird = new Bird();
            ////Duck Object Declaration
            //Duck myDuck = new Duck();
            ////Eagle Object Declaration
            ////Eagle myEagle = new Eagle();
            ////Fish Object Declaration
            ////Fish myFish = new Fish();
            ////Trout Object Declaration
            //Trout myTrout = new Trout();
            ////Shark Object Declaration
            ////Shark myShark = new Shark();

            //////Animal Method calls
            //////myAnimal.Eat();
            //////myAnimal.Reproduce();
            //////myAnimal.Move();

            //////Mammal Method calls
            //////myMammal.Nurse();
            //////myMammal.GiveLiveBirth();

            //////Primate Method calls
            //////myPrimate.UseLargeBrain();
            //////myPrimate.SwingFromTrees();
            //////myPrimate.FierclyProtectTerritory();

            //////Human Method calls
            //myHuman.Work();
            //myHuman.Play();
            //myHuman.Eat();
            //myHuman.Eat("chicken");
            //myHuman.Eat("mashed potatoes and green beans", "utensils");


            //////Bird Method calls
            //////myBird.LayEggs();
            //////myBird.Fly();

            //////Duck Method calls
            //myDuck.Swim();
            //myDuck.GetBeakSlappedOff();
            //myDuck.Eat();
            //myDuck.Eat("grass");
            //myDuck.Eat("grass", "mouth");
            ////Eagle Method calls
            ////myEagle.StunVictim();
            ////myEagle.Soar();

            ////Fish Method calls
            ////myFish.LayEggs();
            ////myFish.Swim();
            ////myFish.GiveLiveBirth();

            ////Trout Method calls

            ////Shark Method calls
            //myShark.KeepMovingToBreathe();
            //myShark.AttackBoats();
            #endregion
            bool pleaseContinue = true;
            //field for the menu
            string reply = "";
            //a do while declaration
            do
            {
                //displaying the menu
                DisplayMenu();
                //getting input from the user
                reply = Input();
                //using a switch case for their answer
                switch (reply)
                {
                //case 1 | Human
                case "1":
                    //clearing the screen
                    ClearScreen();
                    //creating a new human
                    Human myHuman = new Human();
                    myHuman.Name = "Karna";
                    myHuman.Age  = 25;
                    myHuman.Work();
                    myHuman.Play();
                    myHuman.Eat();
                    myHuman.Eat("chicken");
                    myHuman.Eat("mashed potatoes and green beans", "utensils");
                    Utilities.LogIt("NoClient::The user instantiated a human.\n",
                                    Utilities.MessageSeverity.INFORMATIONAL, true);
                    //making sure to break
                    break;

                //case 2 | Duck
                case "2":
                    //clearing the screen
                    ClearScreen();
                    //creating a new Duck
                    Duck myDuck = new Duck();
                    myDuck.Name = "Mallard";
                    myDuck.Age  = 2;
                    myDuck.Swim();
                    myDuck.GetBeakSlappedOff();
                    myDuck.Eat();
                    myDuck.Eat("grass");
                    myDuck.Eat("grass", "mouth");
                    Utilities.LogIt("NoClient::The user instantiated a duck.\n",
                                    Utilities.MessageSeverity.INFORMATIONAL, true);
                    break;

                //case 3 | Trout
                case "3":
                    //clearing the screen
                    ClearScreen();
                    //creating a new Trout
                    Trout myTrout = new Trout();
                    myTrout.Name = "Rainbow";
                    myTrout.Age  = 1;
                    myTrout.AvoidAnglers();
                    myTrout.Eat();
                    myTrout.Eat("baby fish");
                    myTrout.Eat("baby fish", "mouth");
                    Utilities.LogIt("NoClient::The user instantiated a trout.\n",
                                    Utilities.MessageSeverity.INFORMATIONAL, true);
                    break;

                //Case 4 | Exit
                case "4":
                    //clearing the screen
                    ClearScreen();
                    //creating a new Platypus
                    ComposedPlatypus myPlat = new ComposedPlatypus();
                    myPlat.DuckPART.Name = "Platy";
                    myPlat.TroutPART.Age = 1;
                    myPlat.LayEggs();
                    myPlat.SwimLikeDuck();
                    myPlat.SwimLikeFish();
                    myPlat.Nurse();
                    Utilities.LogIt("NoClient::The user instantiated a platypus.\n",
                                    Utilities.MessageSeverity.INFORMATIONAL, true);
                    break;

                //Case 5 | Exit
                case "5":
                    //clearing the screen
                    ClearScreen();
                    //setting pleaseContinue to false
                    pleaseContinue = false;
                    //logging that the user exited the menu.
                    Utilities.LogIt("NoClient::The user exited the NoClient's menu.\n",
                                    Utilities.MessageSeverity.INFORMATIONAL, true);
                    //breaking from the case
                    break;

                //the default case
                default:
                    //clearing the screen
                    ClearScreen();
                    //try to throw a new exception
                    try
                    {
                        //throwing my custom exception
                        throw new CustomExceptions();
                    }
                    //catching the exception
                    catch (CustomExceptions)
                    {
                        //logging the exception
                        Utilities.LogIt("You entered an invalid option in the NoClient menu!\nTry again!\n",
                                        Utilities.MessageSeverity.ERROR, true);
                    }
                    //breaking from the case
                    break;
                }
                //while pleaseContinue is true
            } while (pleaseContinue);
        }