Ejemplo n.º 1
0
 public MyThread(string name, PingPong pp)
 {
     thread         = new Thread(Run);
     pingPongObject = pp;
     thread.Name    = name;
     thread.Start();
 }
Ejemplo n.º 2
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Post["/pingpong"] = _ => {
         int pong;
         int.TryParse(Request.Form["new-number"], out pong);
         PingPong      newPingPong = new PingPong(pong);
         List <string> pingList    = PingPong.Play();
         return(View["pingpong.cshtml", pingList]);
     };
 }
Ejemplo n.º 3
0
 public HomeModule()
 {
     Get["/"] = _ => {
     return View["index.cshtml"];
       };
       Post["/pingpong"] = _ => {
     int pong;
       int.TryParse(Request.Form["new-number"], out pong);
     PingPong newPingPong = new PingPong(pong);
     List<string> pingList = PingPong.Play();
     return View["pingpong.cshtml", pingList];
       };
 }
Ejemplo n.º 4
0
        public void IsPingPong_Forfive_true()
        {
            int number = 5;
            PingPong newPingPong = new PingPong(number);
            List<string> pingList = PingPong.Play();
            List<string> newList = new List<string> { "1", "2", "ping", "4", "pong" };

            foreach (var item in pingList)
            {
              Console.WriteLine("Output: " + item);
            }

            Assert.Equal(newList, pingList);
        }
Ejemplo n.º 5
0
        public void IsPingPong_For3_true()
        {
            int           number      = 3;
            PingPong      newPingPong = new PingPong(number);
            List <string> pingList    = PingPong.Play();
            List <string> newList     = new List <string> {
                "1", "2", "ping"
            };

            foreach (var item in pingList)
            {
                Console.WriteLine("Output: " + item);
            }

            Assert.Equal(newList, pingList);
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            PingPong pp = new PingPong();

            Console.WriteLine("***PinPon Topu Zıpladı***");

            MyThread th1 = new MyThread("Ping", pp);
            MyThread th2 = new MyThread("Pong", pp);


            th1.thread.Join();
            th2.thread.Join();

            Console.WriteLine("***Pinpon Topu Durdu***");
            Console.ReadLine();
        }
Ejemplo n.º 7
0
        public static void Main()
        {
            PingPong newPingPong = new PingPong();

            Console.WriteLine("Welcome to Ping Pong program. This program will count up to a number you enter and replace:");
            Console.WriteLine("- numbers divisible by 3 with 'Ping!'");
            Console.WriteLine("- numbers divisible by 5 with 'Pong!'");
            Console.WriteLine("- numbers divisible by 3 and 5 with 'Ping Pong!'");
            Console.WriteLine("-----------------------");
            Console.WriteLine("Please enter a number: ");
            string stringUserInput = Console.ReadLine();
            int    userInput       = int.Parse(stringUserInput);

            for (int i = 1; i <= userInput; i++)
            {
                Console.WriteLine(newPingPong.ReplacePingPong(i));
            }
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            PingPong game = new PingPong();

            Ping ping = new Ping();
            Pong pong = new Pong();

            game.OnGame += ping.GameMessage;
            game.OnGame += pong.GameMessage;

            string decision;

            do
            {
                game.Play();

                do
                {
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("Хотите сыграть еще раз? (Y/N)\n");
                    Console.ResetColor();

                    decision = Console.ReadLine();

                    Console.WriteLine();

                    if (decision != "Y" && decision != "y" && decision != "N" && decision != "n")
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Не понятно! Попробуем еще раз...\n");
                        Console.ResetColor();
                    }
                } while (decision != "Y" && decision != "y" && decision != "N" && decision != "n");
            } while (decision != "N" && decision != "n");

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine("Игра окончена!");
            Console.ResetColor();
        }
Ejemplo n.º 9
0
 public void Dispose()
 {
     PingPong.DeleteAll();
 }