Exemplo n.º 1
0
        static void Main(string[] args)

        {
            Console.Title = "Server Monitor";
            string path = @"C:\Logs\Server_Monitor.csv";

            Console.WriteLine("Generando Server_Monitor.csv\nEspere 10 segundos hasta que se complete.\nSi tiene el documento Server_Monitor.csv porfavor cerrarlo\nEl archivo se generara en " + path);
            Console.Beep();


            #region Definitions
            //Ram pc
            PerformanceCounter pcRAM = new PerformanceCounter();
            pcRAM.CategoryName = "Memory";
            //pcRAM.CounterName = "% Committed Bytes in Use";
            pcRAM.CounterName = "Available Mbytes";
            pcRAM.NextValue();

            //cores pcs
            //multi core
            int coreCount = 0;
            foreach (var item in new System.Management.ManagementObjectSearcher("Select * from Win32_Processor").Get())
            {
                coreCount += int.Parse(item["NumberOfCores"].ToString());
            }

            PerformanceCounter[] pc = new PerformanceCounter[coreCount];

            for (int i = 0; i < coreCount; i++)
            {
                pc[i] = new PerformanceCounter("Processor", "% Processor Time", i.ToString());

                pc[i].NextValue();
            }
            //temp
            //PerformanceCounter pcTemp = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.TZ00");
            //pcTemp.NextValue();

            //general cpu
            PerformanceCounter pcCPU = new PerformanceCounter();
            pcCPU.CategoryName = "Processor";
            pcCPU.CounterName  = "% Processor Time";
            pcCPU.InstanceName = "_Total";
            pcCPU.NextValue();
            //Drives
            DriveInfo[] drives = DriveInfo.GetDrives();

            string[] driveInfo = new string[drives.Length];
            int      index     = 0;
            #endregion
            System.Threading.Thread.Sleep(5000); //Delay de 5 segundos
            #region Strings
            DateTime date = DateTime.Now;

            string datestring = $"Fecha y hora; { date.ToString() } ";


            string cpuUsageText = $"Uso de CPU total; {(int)pcCPU.NextValue()} % ";

            string ramUsageText = $"RAM disponible; {(int)pcRAM.NextValue()} MB ";

            //string cpuTemperature = $"Temperatura; {(int)(pcTemp.NextValue() - 273.15f)} \u00B0C";

            string[] cpuCoresUsagesText = new string[coreCount];

            for (int i = 0; i < coreCount; i++)
            {
                cpuCoresUsagesText[i] = $"Uso de CPU Core({i}); {(int)pc[i].NextValue()} %";
            }

            foreach (DriveInfo drive in drives)
            {
                driveInfo[index] = ($"Dispositivo {drive.Name}; Espacio Disponible " +
                                    $"{((drive.AvailableFreeSpace/1024)/1024)/1024} GB de {((drive.TotalSize/1024)/1024)/1024} GB");

                index++;
            }

            #endregion

            System.Threading.Thread.Sleep(5000); //Delay de 5 segundos

            // Create a file to write to.
            using (StreamWriter sw = File.CreateText(path))
            {
                sw.Write($"{datestring}\n{cpuUsageText}\n{string.Join("\n", cpuCoresUsagesText)}\n{ramUsageText}\nAlmacenamiento\n{string.Join("\n", driveInfo)}");
                //sw.WriteLine("");
                //sw.WriteLine("");
            }
        }
 private void DisplayIntro()
 {
     WriteLine(">Welcome To My Trash Game!");
     WriteLine("\n>Instructions");
     WriteLine(">Use the arrow keys to move!");
     Write(">Try to reach the goal that looks like this: ");
     ForegroundColor = ConsoleColor.Green;
     Write("X\n");
     ResetColor();
     WriteLine(">To Reach The X, You Must Defeat The Enemy!");
     WriteLine(">If You Collect The Treasure you can Use The Laser To Shoot the Enemey!");
     WriteLine(">Press Z To Fire The Laser!");
     Beep(659, 125); Beep(659, 125); Thread.Sleep(125); Beep(659, 125); Thread.Sleep(167); Beep(523, 125); Console.Beep(659, 125); Thread.Sleep(125); Console.Beep(784, 125); Thread.Sleep(375); Console.Beep(392, 125); Thread.Sleep(375);
     WriteLine("\n>Press Any Key To Start");
     ReadKey(true);
     Clear();
 }
        public List <Nominee> nomineeinput()
        {
            List <Nominee> nomineelist = new List <Nominee>();

            Console.WriteLine("\n\tDo You want to add Nominee(Y/N)");
            Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);

            string n;

label:
            n = Console.ReadLine();
            try
            {
                if (!(n == "y" || n == "Y" || n == "N" || n == "n"))
                {
                    throw new DataEntryException("Please enter valid option (Y/N)");
                }
            }
            catch (DataEntryException e)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                Console.WriteLine(e.Message);
                Console.Beep();
                Console.ForegroundColor = ConsoleColor.Black;
                goto label;
            }

            if (n == "Y" || n == "y")
            {
                Console.ForegroundColor = ConsoleColor.Blue;

                Console.WriteLine("\n\tPlease Enter Nominee details");
                Console.ForegroundColor = ConsoleColor.Black;

                //input nominee name
namelabel:
                Console.ForegroundColor = ConsoleColor.DarkBlue;

                Console.WriteLine("\n\tNominee Name: ");
                Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);

                Console.ForegroundColor = ConsoleColor.Black;

                string nname = Console.ReadLine();
                try
                {
                    Regex rname = new Regex("^[a-zA-Z\\s]+$");
                    if (!(rname.IsMatch(nname)))
                    {
                        throw new DataEntryException("Please Enter Valid Name(Special Characters and numbers not allowed)");
                    }
                }
                catch (DataEntryException e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto namelabel;
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto namelabel;
                }

                //input nominee relation
relationlabel:
                Console.ForegroundColor = ConsoleColor.DarkBlue;

                Console.WriteLine("\n\tNominess's Relation: ");
                Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);

                Console.ForegroundColor = ConsoleColor.Black;

                string nrelation = Console.ReadLine();
                try
                {
                    Regex rrel = new Regex("^[a-zA-Z\\s]+$");
                    if (!(rrel.IsMatch(nrelation)))
                    {
                        throw new DataEntryException("Invalid input");
                    }
                }
                catch (DataEntryException e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto relationlabel;
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto relationlabel;
                }

                //input age
agelabel:
                Console.ForegroundColor = ConsoleColor.DarkBlue;

                Console.WriteLine("\n\tAge: ");
                Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);

                Console.ForegroundColor = ConsoleColor.Black;

                string nagex = Console.ReadLine();
                try
                {
                    Regex rage = new Regex("^[1-9]|[0-9]{2}$");
                    if (!(rage.IsMatch(nagex)))
                    {
                        throw new DataEntryException("Enter valid Age of the nominee");
                    }
                }
                catch (DataEntryException e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto agelabel;
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto agelabel;
                }
                int nage = int.Parse(nagex);

                //input gender
genderlabel:
                Console.ForegroundColor = ConsoleColor.DarkBlue;

                Console.WriteLine("\n\tGender: Enter M for Male or F for Female");
                Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);

                Console.ForegroundColor = ConsoleColor.Black;

                string ngender = Console.ReadLine();
                try
                {
                    if (!(ngender == "M" || ngender == "F" || ngender == "m" || ngender == "f"))
                    {
                        throw new DataEntryException("Please enter M for Male and F for Female");
                    }
                }
                catch (DataEntryException e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto genderlabel;
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto genderlabel;
                }


                //input mob number
moblabel:
                Console.ForegroundColor = ConsoleColor.DarkBlue;

                Console.WriteLine("\n\tMobile Number: (XXXXXXXXXX 10 Digit Number) ");
                Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);

                Console.ForegroundColor = ConsoleColor.Black;

                string nmobx = Console.ReadLine();
                try
                {
                    Regex rmob = new Regex("^[2-9]{1}[0-9]{9}$");
                    if (!(rmob.IsMatch(nmobx.ToString())))
                    {
                        throw new DataEntryException("Please Enter Valid Mobile number(10 digit) and it should not start with  0 or 1)");
                    }
                }
                catch (DataEntryException e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto moblabel;
                }
                catch (Exception e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed; ///Code lines ///

                    Console.WriteLine(e.Message);
                    Console.Beep();
                    Console.ForegroundColor = ConsoleColor.Black;
                    goto moblabel;
                }
                long nmob = long.Parse(nmobx);

                //input address
naddresslabel:
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.WriteLine("\n\tAddress:  (address should include house no,name,street no,area)");
                Console.ForegroundColor = ConsoleColor.Black;
                Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);
                string nadd = Console.ReadLine();

                try
                {
                    if (nadd.Length < 15)
                    {
                        throw new DataEntryException("Please Enter Detailed Address");
                    }
                }
                catch (DataEntryException e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine(e.Message);
                    Console.Beep();
                    goto naddresslabel;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.Beep();
                    goto naddresslabel;
                }

                nomineelist.Add(new Nominee(nname, nrelation, nage, ngender, nmob, nadd));

                Console.WriteLine("\n\tDo You want to add more Nominee(Y/N)");
                Console.SetCursorPosition(Console.CursorLeft + 8, Console.CursorTop);

                goto label;
            }

            return(nomineelist);
        }
Exemplo n.º 4
0
 public void Game_stop()
 {
     Console.Clear();
     Console.WriteLine("Exit");
     Console.Beep();
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            // Configuración de la pantalla
            Console.SetWindowPosition(0, 0);
            Console.SetWindowSize(Console.LargestWindowWidth / 2, Console.LargestWindowHeight - 2);

            // Nombre del alumno
            //Console.

            Changuito changoDeCompras = new Changuito(6);

            Dulce  c1 = new Dulce(Producto.EMarca.Sancor, "ASD012", ConsoleColor.Black);
            Dulce  c2 = new Dulce(Producto.EMarca.Ilolay, "ASD913", ConsoleColor.Red);
            Leche  m1 = new Leche(Producto.EMarca.Pepsico, "HJK789", ConsoleColor.White);
            Leche  m2 = new Leche(Producto.EMarca.Serenisima, "IOP852", ConsoleColor.Blue, Leche.ETipo.Descremada);
            Snacks a1 = new Snacks(Producto.EMarca.Campagnola, "QWE968", ConsoleColor.Gray);
            Snacks a2 = new Snacks(Producto.EMarca.Arcor, "TYU426", ConsoleColor.DarkBlue);
            Snacks a3 = new Snacks(Producto.EMarca.Sancor, "IOP852", ConsoleColor.Green);
            Snacks a4 = new Snacks(Producto.EMarca.Sancor, "TRE321", ConsoleColor.Green);

            // Agrego 8 ítems (los últimos 2 no deberían poder agregarse ni el m1 repetido) y muestro
            changoDeCompras += c1;
            changoDeCompras += c2;
            changoDeCompras += m1;
            changoDeCompras += m1;
            changoDeCompras += m2;
            changoDeCompras += a1;
            changoDeCompras += a2;
            changoDeCompras += a3;
            changoDeCompras += a4;

            Console.WriteLine(changoDeCompras.ToString());
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.ReadKey();
            Console.Clear();

            // Quito un item y muestro
            changoDeCompras -= c1;

            Console.WriteLine(changoDeCompras.ToString());
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.ReadKey();
            Console.Clear();

            // Muestro solo Leches
            Console.Beep();
            Console.WriteLine(Changuito.Mostrar(changoDeCompras, Changuito.ETipo.Leche));
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.ReadKey();
            Console.Clear();

            // Muestro solo Dulces
            Console.Beep();
            Console.WriteLine(Changuito.Mostrar(changoDeCompras, Changuito.ETipo.Dulce));
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.ReadKey();
            Console.Clear();

            // Muestro solo Snacks
            Console.Beep();
            Console.WriteLine(Changuito.Mostrar(changoDeCompras, Changuito.ETipo.Snacks));
            Console.WriteLine("<-------------PRESIONE UNA TECLA PARA SALIR------------->");
            Console.ReadKey();
        }
Exemplo n.º 6
0
 public static void Beep(int _hz, int _time)
 {
     Console.Beep(_hz, _time);
 }
Exemplo n.º 7
0
        private static void subMERCH() //Pkt. 2 - Merchandise
        {
            string continueDialog;
            int    tshirtAntal = 0;
            int    hatAntal    = 0;
            int    varerAntal  = (tshirtAntal + hatAntal);
            int    tshirtPris  = 150;
            int    hatPris     = 100;
            double EurValue    = 7.5; //Det antages at valutaen EURO står fast på 7.5 DKK.
            double tshirtEur   = tshirtPris / EurValue;
            double hatEur      = hatPris / EurValue;

            do
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("Igen i år kan du støtte Roskilde Festival ved at købe merchandise i form af t-shirts og hatte. \n" +
                                  "Disse kan købes ved servicetårnene, hvor der også er fri Wi-Fi og samarithjælp.");
                Console.WriteLine();
                Console.WriteLine("Her kan du få beregnet din pris for et eventuelt køb.");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.WriteLine("Ønsker du at fortsætte?");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("Tast [Y] for ja eller [N] for nej; Du vil blive sendt tilbage til hovedmenuen.");
                Console.ForegroundColor = ConsoleColor.White;
                continueDialog          = Console.ReadLine();
                continueDialog          = continueDialog.ToUpper();
            } while (continueDialog != "Y" && continueDialog != "N" && continueDialog != "y" && continueDialog != "n"); //.ToUpper(); driller, denne metode virker også.

            Console.ForegroundColor = ConsoleColor.DarkGreen;

            if (continueDialog == "Y" || continueDialog == "y")
            {
                Console.Clear();
                Console.WriteLine("Priserne er som følger:");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"Hatte str. Onesize: DKK {hatPris} eller EUR {hatEur.ToString("F")}.");        //Kun 2 decimaler, runder op/ned
                Console.WriteLine($"T-shirts str. S/M/L: DKK {tshirtPris} eller EUR {tshirtEur.ToString("F")}."); //Kun 2 decimaler, runder op/ned
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine();
                Console.WriteLine("Bemærk! Der kan opnås 15% rabat ved køb af mere end 4 varer.");
                Console.WriteLine();

                //---------------------------------------------------------------------------TSHIRT---------------------------------------------------------------------------
                do
                {
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.WriteLine("Hvor mange t-shirts kunne du tænke dig at købe?");
                    Console.WriteLine("(For køb af mere end 10, kontakt venligst personalet)");
                    Console.ForegroundColor = ConsoleColor.White;

                    try
                    {
                        tshirtAntal = int.Parse(Console.ReadLine()); //TryParse virker ikke.
                    }

                    catch (Exception OnlyInt)
                    {
                        Console.WriteLine(OnlyInt.Message);
                        Console.Beep();
                        Console.WriteLine();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Indtast kun hele tal, tak.");
                        System.Threading.Thread.Sleep(1000);
                        Console.WriteLine("Prøv igen. Genstarter fra toppen.");
                        Console.CursorVisible = false;
                        System.Threading.Thread.Sleep(2200);
                        menuQuery   = "";
                        hatAntal    = 0;
                        tshirtAntal = 0;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.CursorVisible   = true;
                        subMERCH();
                        return;
                    }
                } while (tshirtAntal >= 0 && tshirtAntal >= 10);

                Console.ForegroundColor = ConsoleColor.DarkGreen;
                double tshirtTotal    = (tshirtAntal * tshirtPris);
                double tshirttotalEUR = (tshirtTotal) / EurValue;

                if (tshirtAntal >= 1 && tshirtAntal <= 10)
                {
                    Console.Clear();
                    Console.Write($"{tshirtAntal} t-shirt(s) koster DKK");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write($" {tshirtTotal}");
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.Write(" eller EUR ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"{tshirttotalEUR.ToString("F")}.");
                    Console.ForegroundColor = ConsoleColor.DarkGreen;


                    if (tshirtAntal < 5)
                    {
                        Console.WriteLine();
                        Console.Write("Køb ");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write($"{ 5 - tshirtAntal} ");
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("genstand(e) mere for at opnå 15 % rabat på hele dit køb.");
                    }
                }

                else if (tshirtAntal >= 0)
                {
                    Console.Clear();
                    Console.WriteLine("Ingen t-shirts registreret.");
                }

                //---------------------------------------------------------------------------HAT---------------------------------------------------------------------------
                do
                {
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.WriteLine("Hvor mange hatte kunne du tænke dig at købe?");
                    Console.WriteLine("(For køb af mere end 10, kontakt venligst personalet)");
                    Console.ForegroundColor = ConsoleColor.White;

                    try
                    {
                        hatAntal = int.Parse(Console.ReadLine()); //TryParse virker ikke.
                    }

                    catch (Exception)
                    {
                        Console.Beep();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Indtast kun hele tal, tak.");
                        System.Threading.Thread.Sleep(1000);
                        Console.WriteLine("Prøv igen. Genstarter fra toppen.");
                        Console.CursorVisible = false;
                        System.Threading.Thread.Sleep(2200);
                        menuQuery   = "";
                        hatAntal    = 0;
                        tshirtAntal = 0;
                        Console.Clear();
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.CursorVisible   = true;
                        subMERCH();
                        return;
                    }
                } while (hatAntal >= 0 && hatAntal >= 10);

                Console.ForegroundColor = ConsoleColor.DarkGreen;
                double hatTotal    = (hatAntal * hatPris);
                double hatTotalEur = (hatTotal) / EurValue;

                if (hatAntal >= 1 && hatAntal <= 10)
                {
                    Console.Clear();
                    Console.Write($"{hatAntal} hat(te) koster DKK");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write($" {hatTotal}");
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.Write(" eller EUR ");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"{hatTotalEur.ToString("F")}.");
                    Console.ForegroundColor = ConsoleColor.DarkGreen;


                    if ((hatAntal + tshirtAntal) < 5)
                    {
                        Console.WriteLine();
                        Console.Write("Køb ");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write($"{ 5 - (hatAntal + tshirtAntal)} ");
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("genstand(e) mere for at opnå 15 % rabat på hele dit køb.");
                    }
                }

                else if (hatAntal >= 0)
                {
                    Console.Clear();
                    Console.WriteLine("Ingen hatte registreret.");
                    Console.WriteLine();
                }

                Console.WriteLine();
                Console.WriteLine("Du har valgt {0} t-shirt(s) og {1} hat(te).", tshirtAntal, hatAntal);
                Console.WriteLine();
                Console.WriteLine("Tryk på en vilkårlig tast for at fortsætte:");
                Udregner();

                double eurSum = ((tshirtAntal * tshirtPris) / 7.5 + (hatAntal * hatPris) / 7.5);
                double dkkSum = (tshirtTotal) + (hatTotal);
                Console.WriteLine("Din total er som følger:");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"{tshirtAntal} t-shirt(s) á DKK {tshirtPris}, i alt {tshirtTotal} DKK eller {tshirttotalEUR.ToString("F")} EUR.");
                Console.WriteLine();
                Console.WriteLine($"{hatAntal} hat(te) á DKK {hatPris}, i alt {hatTotal} DKK eller {hatTotalEur.ToString("F")} EUR.");
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine();

                double discountDKK = (dkkSum) * 0.85;
                double discountEUR = (eurSum) * 0.85;
                double SavedDKK    = (dkkSum) * 0.15;
                double savedEUR    = (eurSum) * 0.15;

                if ((hatAntal + tshirtAntal) <= 4) //VarerAntal virker ikke altid -- Her kunne man have indsat "Hvis bare du havde brugt lidt flere genstande, kunne du have sparet 15%"
                {
                    Console.WriteLine("Alt i alt:");
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("DKK {0} eller EUR {1}.", dkkSum, eurSum.ToString("F"));
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                }

                else if ((hatAntal + tshirtAntal) >= 5) //VarerAntal virker ikke altid
                {
                    Console.WriteLine("I alt:");
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("DKK {0} eller EUR {1}.", dkkSum, eurSum.ToString("F"));
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.WriteLine();
                    Console.WriteLine("Eftersom du har valgt mere end 4 varer, vil du opnå 15% rabat på hele dit køb.");
                    Console.WriteLine();
                    Console.WriteLine("Alt i alt:");
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("DKK {0} eller EUR {1}.", discountDKK, discountEUR.ToString("F"));
                    Console.WriteLine();
                    Console.WriteLine("Det vil sige at du har sparet DKK {0} eller EUR {1}.", SavedDKK, savedEUR.ToString("F"));
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                }
            }

            if (continueDialog == "N" || continueDialog == "n")
            {
                Console.Clear();
                Console.WriteLine("Du vil nu blive sendt tilbage til hovedmenuen.");
                Console.CursorVisible = false;
                System.Threading.Thread.Sleep(2200);
                menuQuery   = "";
                hatAntal    = 0;
                tshirtAntal = 0;
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.CursorVisible   = true;
                Menu();
            }

            ReturnMenu();
        }
Exemplo n.º 8
0
 void Pause()
 {
     Console.Beep();
     Console.ReadKey();
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Console.Title = "HAWT DAWGZ";
            Console.SetWindowSize(55, 20);
            Console.SetBufferSize(55, 20);
            Console.CursorVisible = false;
            int        centerX   = Console.BufferWidth / 2 - 6;
            int        centerY   = Console.BufferHeight / 2;
            MarioTheme playMario = new MarioTheme();
            DrawMenu   drawMenu  = new DrawMenu();

            bool loop = true;

            /*string menu = "Controls (notes below buttons on keyboard):" +
             *            "\nQ W\t E R T\t    Y U\t     I O P\t[ ]\nA Asharp B C Csharp D Dsharp E" +
             *            " F Fsharp G Gsharp\n\nM - Mario theme"; */
            drawMenu.MenuShow("WHOLE");
            int dur = (int)Duration.WHOLE;

            while (loop)
            {
                ConsoleKeyInfo ui = Console.ReadKey(true);
                switch (ui.Key)
                {
                case ConsoleKey.M:
                    playMario.MarioThemePlay();
                    break;

                    #region DURATION
                case ConsoleKey.D1:
                    drawMenu.MenuShow("WHOLE");
                    dur = (int)Duration.WHOLE;
                    break;

                case ConsoleKey.D2:
                    drawMenu.MenuShow("HALF");
                    dur = (int)Duration.HALF;
                    break;

                case ConsoleKey.D3:
                    drawMenu.MenuShow("QUARTER");
                    dur = (int)Duration.QUARTER;
                    break;

                case ConsoleKey.D4:
                    drawMenu.MenuShow("EIGHTH");
                    dur = (int)Duration.EIGHTH;
                    break;

                case ConsoleKey.D5:
                    drawMenu.MenuShow("SIXTEENTH");
                    dur = (int)Duration.SIXTEENTH;
                    break;
                    #endregion

                    #region NOTES
                case ConsoleKey.Q:
                    Console.Beep((int)Tone.A, dur);
                    break;

                case ConsoleKey.W:
                    Console.Beep((int)Tone.Asharp, dur);
                    break;

                case ConsoleKey.E:
                    Console.Beep((int)Tone.B, dur);
                    break;

                case ConsoleKey.R:
                    Console.Beep((int)Tone.C, dur);
                    break;

                case ConsoleKey.T:
                    Console.Beep((int)Tone.Csharp, dur);
                    break;

                case ConsoleKey.Y:
                    Console.Beep((int)Tone.D, dur);
                    break;

                case ConsoleKey.U:
                    Console.Beep((int)Tone.Dsharp, dur);
                    break;

                case ConsoleKey.I:
                    Console.Beep((int)Tone.E, dur);
                    break;

                case ConsoleKey.O:
                    Console.Beep((int)Tone.F, dur);
                    break;

                case ConsoleKey.P:
                    Console.Beep((int)Tone.Fsharp, dur);
                    break;

                case ConsoleKey.Oem4:
                    Console.Beep((int)Tone.G, dur);
                    break;

                case ConsoleKey.Oem6:
                    Console.Beep((int)Tone.Gsharp, dur);
                    break;
                    #endregion
                }
            }
        }
Exemplo n.º 10
0
        private static string ConsoleReadLine()
        {
            Console.Beep();

            return(Console.ReadLine());
        }
Exemplo n.º 11
0
        internal static async Task <string> GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF)
        {
            if (userInputType == ASF.EUserInputType.Unknown)
            {
                return(null);
            }

            if (ASF.GlobalConfig.Headless)
            {
                ASF.ArchiLogger.LogGenericWarning(Strings.ErrorUserInputRunningInHeadlessMode);

                return(null);
            }

            await ConsoleSemaphore.WaitAsync().ConfigureAwait(false);

            string result;

            try {
                OnUserInputStart();

                try {
                    Console.Beep();

                    switch (userInputType)
                    {
                    case ASF.EUserInputType.DeviceID:
                        Console.Write(Bot.FormatBotResponse(Strings.UserInputDeviceID, botName));
                        result = ConsoleReadLine();

                        break;

                    case ASF.EUserInputType.Login:
                        Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamLogin, botName));
                        result = ConsoleReadLine();

                        break;

                    case ASF.EUserInputType.Password:
                        Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamPassword, botName));
                        result = ConsoleReadLineMasked();

                        break;

                    case ASF.EUserInputType.SteamGuard:
                        Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamGuard, botName));
                        result = ConsoleReadLine();

                        break;

                    case ASF.EUserInputType.SteamParentalCode:
                        Console.Write(Bot.FormatBotResponse(Strings.UserInputSteamParentalCode, botName));
                        result = ConsoleReadLineMasked();

                        break;

                    case ASF.EUserInputType.TwoFactorAuthentication:
                        Console.Write(Bot.FormatBotResponse(Strings.UserInputSteam2FA, botName));
                        result = ConsoleReadLine();

                        break;

                    default:
                        ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(userInputType), userInputType));
                        Console.Write(Bot.FormatBotResponse(string.Format(Strings.UserInputUnknown, userInputType), botName));
                        result = ConsoleReadLine();

                        break;
                    }

                    if (!Console.IsOutputRedirected)
                    {
                        Console.Clear();                         // For security purposes
                    }
                } catch (Exception e) {
                    OnUserInputEnd();
                    ASF.ArchiLogger.LogGenericException(e);

                    return(null);
                }

                OnUserInputEnd();
            } finally {
                ConsoleSemaphore.Release();
            }

            return(!string.IsNullOrEmpty(result) ? result.Trim() : null);
        }
Exemplo n.º 12
0
    public void GameLoopEsp()
    {
        bool exit = false;
        int  nIsAbsent;

        do
        {
            do
            {
                ShowExitEsp();
                for (int i = 0; i < Players.Count - 1; i++)
                {
                    //1 Check user input
                    MovementsEsp();

                    // Payment of blinds
                    if (Players[i].bigBlind)
                    {
                        int big = 200;
                        Players[i].Chips -= big;
                        pot += big;
                    }

                    if (Players[i].smallBlind)
                    {
                        int small = 100;
                        Players[i].Chips -= small;
                        pot += small;
                    }

                    if (!isAbsent)
                    {
                        //2 Movements
                        if (Index < Players.Count - 1)
                        {
                            Index++;
                            // Sound to inform about the turn of another player
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                        else
                        {
                            Index = 0;
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                    }
                    else
                    {
                        nIsAbsent = Index;
                        if (Index < Players.Count - 1)
                        {
                            Index++;
                        }
                        else
                        {
                            Index = 0;
                        }
                    }
                    DrawCard.UpdateChipsEsp(Players);
                }

                // 3 firsts cards of the middle
                if (allIsPlay)
                {
                    Flop(Deck);
                    allIsPlay = false;
                    for (int i = 0; i < Players.Count; i++)
                    {
                        MovementsEsp();

                        if (!isAbsent)
                        {
                            //2 Movements
                            if (Index < Players.Count - 1)
                            {
                                Index++;
                                // Sound to inform about the turn of another player
                                Console.Beep(600, 1000);
                                //Update Pot
                                DrawCard.DrawPot(pot);
                                DrawCard.UpdateChipsEsp(Players);
                            }
                            else
                            {
                                Index = 0;
                                Console.Beep(600, 1000);
                                //Update Pot
                                DrawCard.DrawPot(pot);
                                DrawCard.UpdateChipsEsp(Players);
                            }
                        }
                        else
                        {
                            nIsAbsent = Index;
                            if (Index < Players.Count - 1)
                            {
                                Index++;
                            }
                            else
                            {
                                Index = 0;
                            }
                        }
                    }
                }
                else
                {
                    allIsPlay = false;
                }


                if (allIsPlay)
                {
                    Turn(Deck);
                    for (int i = 0; i < Players.Count; i++)
                    {
                        MovementsEsp();

                        if (Index < Players.Count - 1)
                        {
                            Index++;
                            Console.Beep(600, 1000);
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                        else
                        {
                            Index = 0;
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                    }
                }
                else
                {
                    allIsPlay = false;
                }

                // The last card of the middle
                if (allIsPlay)
                {
                    River(Deck);
                    for (int i = 0; i < Players.Count; i++)
                    {
                        MovementsEsp();

                        if (Index < Players.Count - 1)
                        {
                            Index++;
                            Console.Beep(600, 1000);
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                        else
                        {
                            Index = 0;
                            Console.Beep(600, 1000);
                            //Update Pot
                            DrawCard.DrawPot(pot);
                            DrawCard.UpdateChipsEsp(Players);
                        }
                    }
                }
                else
                {
                    allIsPlay = false;
                }
            } while (!allIsPlay);

            for (int timesToShuffle = 0; timesToShuffle < 10; timesToShuffle++)
            {
                Deck.Shuffle();
            }

            // Update cards after the turn
            CheckCardsEsp(Players, Deck);
            DrawCard.UpdateChipsEsp(Players);
            DrawCard.DrawTableEsp(Deck);
            DrawCard.DrawEsp(Players, Deck);
            //DrawCard.DrawResult(Players);
            pot   = 0;
            Index = 0;
            Deck.Reset();
            round++;
        } while (!exit);
    }
Exemplo n.º 13
0
        private async void bn_Execute_Click(object sender, EventArgs e)
        {
            string imagepath = tb_image.Text;

            if (imagepath == "")
            {
                MessageBox.Show("请加载要处理的影像!");
                return;
            }
            string rulepath = tb_ruleset.Text;

            if (rulepath == "")
            {
                MessageBox.Show("请加载规则集!");
                return;
            }
            XmlInfo classDet = new XmlInfo(rulepath);

            classDet.ReadRuleSet();
            string OutShpPath        = classDet.SearchAlgoParams();
            string ClassficationPath = classDet.SearchAlgoParams2();

            if (OutShpPath == "" && ClassficationPath == "")
            {
                MessageBox.Show("此规则集有误,或本系统暂不支持该规则集,\n请修改规则集并重试!");
                return;
            }
            if (RuleSetMessage.AlgoOptions != 1 && RuleSetMessage.AlgoOptions != 2)
            {
                if (ClassficationPath != "")
                {
                    MessageBox.Show("此规则集用于分类,请先在分类参数窗口中\n" +
                                    "进行相关设置,并点击确定按钮!");
                    return;
                }
                else if (OutShpPath != "")
                {
                    MessageBox.Show("此规则集用于分割,请先在多尺度分割参数窗口中\n" +
                                    "进行相关设置,并点击确定按钮!");
                    return;
                }
            }
            string project     = tb_projectPath.Text;
            string projectName = tb_projetName.Text;

            Lb_result.Text = "开始执行";
            Task       t2 = ProgressbarStatus();
            Task <int> t1 = AnalyseImageAsync2(imagepath, rulepath, project, projectName);
            await Task.WhenAny(t1, t2);

            if (t1.Result == 0)
            {
                Lb_result.Text             = "执行成功";
                RuleSetMessage.AlgoOptions = 0;
                NotcancelFlag = false;
                Console.Beep(1000, 1000);
                MessageBox.Show("完成");
                Close();
            }
            else
            {
                Lb_result.Text             = "执行失败,错误码为:" + t1.Result.ToString();
                RuleSetMessage.AlgoOptions = 0;
                NotcancelFlag        = false;
                progressBar1.Visible = false;
            }
        }
Exemplo n.º 14
0
 public void Sound()
 {
     Console.WriteLine("Hallo Welt");
     Console.Beep();
 }
Exemplo n.º 15
0
 static void Main(string[] args)
 {
     Console.WriteLine("Beep");
     Console.Beep();
     Console.ReadKey();
 }
Exemplo n.º 16
0
 private void button2_Click(object sender, EventArgs e)
 {
     Console.Beep(297, 300);
 }
Exemplo n.º 17
0
        private void inputListener_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            Console.Beep();
            Console.WriteLine(e.ToString());

            Console.Beep();
            switch (e.Result.Text)
            {
            case "draw":
                inputListener.RecognizeAsync(RecognizeMode.Multiple);
                masterEngine.RecognizeAsyncCancel();
                break;

            case "line":
                inputListener.RecognizeAsync(RecognizeMode.Multiple);
                masterEngine.RecognizeAsyncCancel();
                if (!type)
                {
                    command += e.Result.Text + " ";
                    type     = true;
                }

                break;

            case "triangle":
                inputListener.RecognizeAsync(RecognizeMode.Multiple);
                masterEngine.RecognizeAsyncCancel();
                if (!type)
                {
                    command += e.Result.Text + " ";
                    type     = true;
                }

                break;

            case "square":
                inputListener.RecognizeAsync(RecognizeMode.Multiple);
                masterEngine.RecognizeAsyncCancel();
                if (!type)
                {
                    command += e.Result.Text + " ";
                    type     = true;
                }

                break;

            case "b 5":
                inputListener.RecognizeAsync(RecognizeMode.Multiple);
                masterEngine.RecognizeAsyncCancel();
                if (!coordinate)
                {
                    command   += e.Result.Text;
                    coordinate = true;
                }
                //return somehow and/or start listening for tone/volume
                Console.WriteLine(command);
                //can use != notation instead, this is just for style points
                readToReturn?.Invoke(command);

                reset();
                break;


            default:
                // Console.WriteLine("i didn't get that");

                break;
            }
        }
Exemplo n.º 18
0
 private void button5_Click(object sender, EventArgs e)
 {
     Console.Beep(396, 300);
 }
Exemplo n.º 19
0
 public static void MarioBros()
 {
     Console.Beep(659, 125);
     Console.Beep(659, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(167);
     Console.Beep(523, 125);
     Console.Beep(659, 125);
     Thread.Sleep(125);
     Console.Beep(784, 125);
     Thread.Sleep(375);
     Console.Beep(392, 125);
     Thread.Sleep(375);
     Console.Beep(523, 125);
     Thread.Sleep(250);
     Console.Beep(392, 125);
     Thread.Sleep(250);
     Console.Beep(330, 125);
     Thread.Sleep(250);
     Console.Beep(440, 125);
     Thread.Sleep(125);
     Console.Beep(494, 125);
     Thread.Sleep(125);
     Console.Beep(466, 125);
     Thread.Sleep(42);
     Console.Beep(440, 125);
     Thread.Sleep(125);
     Console.Beep(392, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(125);
     Console.Beep(784, 125);
     Thread.Sleep(125);
     Console.Beep(880, 125);
     Thread.Sleep(125);
     Console.Beep(698, 125);
     Console.Beep(784, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(125);
     Console.Beep(523, 125);
     Thread.Sleep(125);
     Console.Beep(587, 125);
     Console.Beep(494, 125);
     Thread.Sleep(125);
     Console.Beep(523, 125);
     Thread.Sleep(250);
     Console.Beep(392, 125);
     Thread.Sleep(250);
     Console.Beep(330, 125);
     Thread.Sleep(250);
     Console.Beep(440, 125);
     Thread.Sleep(125);
     Console.Beep(494, 125);
     Thread.Sleep(125);
     Console.Beep(466, 125);
     Thread.Sleep(42);
     Console.Beep(440, 125);
     Thread.Sleep(125);
     Console.Beep(392, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(125);
     Console.Beep(784, 125);
     Thread.Sleep(125);
     Console.Beep(880, 125);
     Thread.Sleep(125);
     Console.Beep(698, 125);
     Console.Beep(784, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(125);
     Console.Beep(523, 125);
     Thread.Sleep(125);
     Console.Beep(587, 125);
     Console.Beep(494, 125);
     Thread.Sleep(375);
     Console.Beep(784, 125);
     Console.Beep(740, 125);
     Console.Beep(698, 125);
     Thread.Sleep(42);
     Console.Beep(622, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(167);
     Console.Beep(415, 125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Thread.Sleep(125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Console.Beep(587, 125);
     Thread.Sleep(250);
     Console.Beep(784, 125);
     Console.Beep(740, 125);
     Console.Beep(698, 125);
     Thread.Sleep(42);
     Console.Beep(622, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(167);
     Console.Beep(698, 125);
     Thread.Sleep(125);
     Console.Beep(698, 125);
     Console.Beep(698, 125);
     Thread.Sleep(625);
     Console.Beep(784, 125);
     Console.Beep(740, 125);
     Console.Beep(698, 125);
     Thread.Sleep(42);
     Console.Beep(622, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(167);
     Console.Beep(415, 125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Thread.Sleep(125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Console.Beep(587, 125);
     Thread.Sleep(250);
     Console.Beep(622, 125);
     Thread.Sleep(250);
     Console.Beep(587, 125);
     Thread.Sleep(250);
     Console.Beep(523, 125);
     Thread.Sleep(1125);
     Console.Beep(784, 125);
     Console.Beep(740, 125);
     Console.Beep(698, 125);
     Thread.Sleep(42);
     Console.Beep(622, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(167);
     Console.Beep(415, 125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Thread.Sleep(125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Console.Beep(587, 125);
     Thread.Sleep(250);
     Console.Beep(784, 125);
     Console.Beep(740, 125);
     Console.Beep(698, 125);
     Thread.Sleep(42);
     Console.Beep(622, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(167);
     Console.Beep(698, 125);
     Thread.Sleep(125);
     Console.Beep(698, 125);
     Console.Beep(698, 125);
     Thread.Sleep(625);
     Console.Beep(784, 125);
     Console.Beep(740, 125);
     Console.Beep(698, 125);
     Thread.Sleep(42);
     Console.Beep(622, 125);
     Thread.Sleep(125);
     Console.Beep(659, 125);
     Thread.Sleep(167);
     Console.Beep(415, 125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Thread.Sleep(125);
     Console.Beep(440, 125);
     Console.Beep(523, 125);
     Console.Beep(587, 125);
     Thread.Sleep(250);
     Console.Beep(622, 125);
     Thread.Sleep(250);
     Console.Beep(587, 125);
     Thread.Sleep(250);
     Console.Beep(523, 125);
 }
Exemplo n.º 20
0
 private void button7_Click(object sender, EventArgs e)
 {
     Console.Beep(495, 300);
 }
Exemplo n.º 21
0
 public Bullet(MatrixCoords topLeft, char[,] body)
     : base(topLeft, body)
 {
     //Here we can change the beep melody of the fire
     Console.Beep(800, 100);
 }
Exemplo n.º 22
0
        /// <summary>
        /// 缺省窗口过程
        /// </summary>
        /// <param name="m">消息</param>
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case API.WM_CHAR:
            {
                int nKey = API.LoWord(m.WParam.ToInt32());
                switch (nKey)
                {
                case (int)Keys.Tab:
                {
                    // 禁止Tab键的作用 2008/7/28
                    Console.Beep();
                    return;
                }
                break;

                case (int)Keys.Enter:
                {
                }
                break;

                case (int)Keys.Back:
                {
                    // 禁止Backspace键的作用 2008/7/4
                    Console.Beep();
                    return;
                }
                break;

                default:
                {
                    if ((Control.ModifierKeys == Keys.Control)
                        // || Control.ModifierKeys == Keys.Shift    // 2009/9/18 changed
                        || Control.ModifierKeys == Keys.Alt)
                    {
                        break;
                    }
                    int nOldSelectionStart = this.SelectionStart;
                    if (nOldSelectionStart < this.Text.Length)
                    {
                        // 避免多余的TextChanged动作
                        this.fixedFieldCtrl.m_nDisableTextChanged++;
                        this.Text = this.Text.Remove(this.SelectionStart, 1);
                        this.fixedFieldCtrl.m_nDisableTextChanged--;
                        this.SelectionStart = nOldSelectionStart;
                    }

                    base.DefWndProc(ref m);

                    if (this.SelectionStart >= this.MaxLength &&
                        this.nIndex < fixedFieldCtrl.LineCount - 1)
                    {
                        fixedFieldCtrl.SwitchFocus(this.nIndex + 1,
                                                   CaretPosition.FirstChar);
                    }

                    return;
                }
                break;
                }
            }
            break;
            }
            base.DefWndProc(ref m);
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            int selection;

            do
            {
                //Main Menu
                Console.Clear();
                Console.WriteLine("--Main Menu--");
                Console.WriteLine("1. Start ");
                Console.WriteLine("2. View Score");
                Console.WriteLine("3. Help Page");
                Console.WriteLine("4. Exit");
                Console.WriteLine("Choose one to proceed...");
                Console.Write("-->");
                selection = int.Parse(Console.ReadLine());

                if (selection == 1)
                {
                    // Difficulty and life system
                    string difficulty = " ";
                    int    life       = 5;

                    // You need to pick a difficulty
                    do
                    {
                        Console.WriteLine("\nStage Mode- easy,normal,hard");
                        Console.Write("Select your difficulty : ");
                        difficulty = Console.ReadLine();
                    } while (difficulty != "easy" && difficulty != "normal" && difficulty != "hard");

                    // start game
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();

                    // display this char on the console during the game
                    char           ch       = '*';
                    bool           gameLive = true;
                    ConsoleKeyInfo consoleKey;                     // holds whatever key is pressed
                    int            tail = 3;

                    // location info & display
                    int x = 0, y = 2;                     // y is 2 to allow the top row for directions & space
                    int dx = 1, dy = 0;
                    int consoleWidthLimit  = 79;
                    int consoleHeightLimit = 24;
                    int score              = 0;

                    // Creating space
                    string space = "   ";


                    //Position of food
                    Random rand = new Random();
                    char   food = '@';
                    int    foodx = 0, foody = 0;
                    foodx = rand.Next(2, consoleWidthLimit);
                    foody = rand.Next(2, consoleHeightLimit);

                    //Special food
                    char s_food = '+';
                    int  s_foodx = 0, s_foody = 0;
                    s_foodx = rand.Next(2, consoleWidthLimit);
                    s_foody = rand.Next(2, consoleHeightLimit);

                    //Position of Obstacles
                    string obstacle1 = "||";
                    int    ob1x = 0, ob1y = 0;
                    ob1x = rand.Next(0, consoleWidthLimit);
                    ob1y = rand.Next(0, consoleHeightLimit);

                    string obstacle2 = "||";
                    int    ob2x = 0, ob2y = 0;
                    ob2x = rand.Next(0, consoleWidthLimit);
                    ob2y = rand.Next(0, consoleHeightLimit);

                    // clear to color
                    Console.BackgroundColor = ConsoleColor.DarkCyan;
                    Console.Clear();

                    // delay to slow down the character movement so you can see it
                    int delayInMillisecs = 50;

                    // count steps for food each time the snake moves
                    int stepFood = 0;
                    // count steps for bounty food each time the snake moves
                    int stepBonusFood = 0;
                    int foodInterval  = 100;

                    //whether to keep trails
                    bool trail = false;


                    do                     // until escape
                    {
                        // print directions at top, then restore position
                        // save then restore current color
                        ConsoleColor cc = Console.ForegroundColor;
                        Console.ForegroundColor = ConsoleColor.Black;
                        Console.SetCursorPosition(0, 0);
                        Console.WriteLine("Arrows move up/down/right/left. Press 'esc' quit.");
                        Console.WriteLine("Obtain score at least 20 to win the game...");
                        Console.WriteLine("Score: " + score);
                        Console.WriteLine("Life: " + life);
                        Console.SetCursorPosition(x, y);
                        Console.ForegroundColor = cc;

                        // see if a key has been pressed
                        if (Console.KeyAvailable)
                        {
                            // get key and use it to set options
                            consoleKey = Console.ReadKey(true);
                            switch (consoleKey.Key)
                            {
                            case ConsoleKey.UpArrow:                                     //UP
                                dx = 0;
                                dy = -1;
                                Console.ForegroundColor = ConsoleColor.Red;
                                break;

                            case ConsoleKey.DownArrow:                                     // DOWN
                                dx = 0;
                                dy = 1;
                                Console.ForegroundColor = ConsoleColor.Cyan;
                                break;

                            case ConsoleKey.LeftArrow:                                     //LEFT
                                dx = -1;
                                dy = 0;
                                Console.ForegroundColor = ConsoleColor.Green;
                                break;

                            case ConsoleKey.RightArrow:                                     //RIGHT
                                dx = 1;
                                dy = 0;
                                Console.ForegroundColor = ConsoleColor.Black;
                                break;

                            case ConsoleKey.Escape:                                     //END
                                gameLive = false;
                                break;
                            }
                        }


                        Console.SetCursorPosition(ob1x, ob1y);
                        Console.Write(obstacle1);

                        Console.SetCursorPosition(ob2x, ob2y);
                        Console.Write(obstacle2);


                        //Snake eat food
                        if ((x == foodx && y == foody) || stepFood > foodInterval)
                        {
                            //Increase score when snake eat the food
                            if (x == foodx && y == foody)
                            {
                                score += 5;
                                space += " ";
                                tail++;
                            }
                            //Remove the food
                            Console.SetCursorPosition(foodx, foody);
                            Console.Write(' ');
                            //New food
                            foodx    = rand.Next(2, consoleWidthLimit - 1);
                            foody    = rand.Next(2, consoleHeightLimit - 1);
                            stepFood = 0;
                        }
                        ++stepFood;

                        Console.SetCursorPosition(foodx, foody);
                        Console.Write(food);


                        //Snake eat bonus food
                        if (x == s_foodx && y == s_foody || stepBonusFood > foodInterval)
                        {
                            //Increase score when snake eat the food
                            if (x == s_foodx && y == s_foody)
                            {
                                score += 10;
                                Console.Beep();
                            }
                            //Remove the bonus food
                            Console.SetCursorPosition(s_foodx, s_foody);
                            Console.Write(' ');
                            //New bonus food
                            s_foodx       = rand.Next(2, consoleWidthLimit - 1);
                            s_foody       = rand.Next(2, consoleHeightLimit - 1);
                            stepBonusFood = 0;
                        }
                        ++stepBonusFood;

                        Console.SetCursorPosition(s_foodx, s_foody);
                        Console.Write(s_food);


                        // If hit obstacle, decrease life
                        if (x == ob1x && y == ob1y)
                        {
                            if (difficulty == "easy")
                            {
                                life--;
                            }
                            if (difficulty == "normal")
                            {
                                life -= 2;
                            }
                            if (difficulty == "hard")
                            {
                                life -= 4;
                            }
                            ob1x = rand.Next(0, consoleWidthLimit - 1);
                            ob1y = rand.Next(0, consoleHeightLimit - 1);
                        }

                        if (x == ob2x && y == ob2y)
                        {
                            if (difficulty == "easy")
                            {
                                life--;
                            }
                            if (difficulty == "normal")
                            {
                                life -= 2;
                            }
                            if (difficulty == "hard")
                            {
                                life -= 4;
                            }
                            ob2x = rand.Next(0, consoleWidthLimit - 1);
                            ob2y = rand.Next(0, consoleHeightLimit - 1);
                        }

                        // End the game if snake's life hit 0
                        if (life <= 0)
                        {
                            gameLive = false;
                            break;
                        }

                        //Set winning condition
                        if (score >= 20)
                        {
                            Console.Clear();
                            Console.WriteLine("Congratulations You win!!!");
                            Console.WriteLine("Press any key to proceed!");
                            Console.ReadKey();
                            gameLive = false;
                            break;
                        }

                        // find the current position in the console grid & erase the character there if don't want to see the trail
                        Console.SetCursorPosition(x, y);
                        if (trail == false)
                        {
                            Console.Write(space);
                        }

                        // calculate the new position
                        // note x set to 0 because we use the whole width, but y set to 1 because we use top row for instructions
                        x += dx;
                        if (x > consoleWidthLimit)
                        {
                            x = 0;
                        }
                        if (x < 0)
                        {
                            x = consoleWidthLimit;
                        }

                        y += dy;
                        if (y > consoleHeightLimit)
                        {
                            y = 2;                             // 2 due to top spaces used for directions
                        }
                        if (y < 2)
                        {
                            y = consoleHeightLimit;
                        }

                        // write the character in the new position
                        Console.SetCursorPosition(x, y);
                        for (int i = 0; i < tail; i++)
                        {
                            if (Console.ForegroundColor == ConsoleColor.Red)
                            {
                                if (y < tail)
                                {
                                    y = consoleHeightLimit;
                                }
                                Console.SetCursorPosition(x, y - i);
                            }
                            else if (Console.ForegroundColor == ConsoleColor.Cyan)
                            {
                                if (y > consoleHeightLimit)
                                {
                                    y = tail;
                                }
                                Console.SetCursorPosition(x, y + i);
                            }

                            Console.Write(ch);
                        }
                        // pause to allow eyeballs to keep up
                        System.Threading.Thread.Sleep(delayInMillisecs);
                    } while (gameLive);

                    if (gameLive == false)
                    {
                        Console.Write("Input your name : ");
                        string       name = Console.ReadLine();
                        StreamWriter sw   = File.AppendText("Score.txt");
                        sw.WriteLine(name + "\t" + score);
                        sw.Close();
                    }
                }
                else if (selection == 2)
                {
                    scoreboard();
                }
                else if (selection == 3)
                {
                    helppage();
                }
                else if (selection == 4)
                {
                    //Exit
                    Console.WriteLine("Program terminated");
                    Console.WriteLine("Press any key again to exit...");
                    Console.ReadKey();
                }
            } while (selection != 4);
        }
Exemplo n.º 24
0
        // 接管Ctrl+各种键
        protected override bool ProcessDialogKey(
            Keys keyData)
        {
            // Ctrl + A 自动录入功能
            if ((keyData & Keys.Control) == Keys.Control &&
                (keyData & (~Keys.Control)) == Keys.A)
            {
                // MessageBox.Show(this, "Ctrl+A");
                string strValue = "";
                string strError = "";

                //
                Cursor oldcursor = this.Cursor;
                this.Cursor = Cursors.WaitCursor;   // 出现沙漏

                int nOldSelectionStart = this.SelectionStart;
                this.Enabled = false;
                //

                int nRet = fixedFieldCtrl.GetDefaultValue(this.nIndex,
                                                          out strValue,
                                                          out strError);

                //
                this.Enabled = true;
                this.Focus();
                this.SelectionStart = nOldSelectionStart;

                this.Cursor = oldcursor;
                //


                if (nRet == 0)
                {
                    Console.Beep();
                }
                else if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                }
                else
                {
                    if (strValue == null)
                    {
                        strValue = "";
                    }

                    if (strValue.Length < this.MaxLength)
                    {
                        strValue = strValue.PadRight(this.MaxLength, ' ');
                        Console.Beep();
                    }
                    else if (strValue.Length > this.MaxLength)
                    {
                        strValue = strValue.Substring(0, this.MaxLength);
                        Console.Beep();
                    }

                    this.Text = strValue;
                }

                return(true);
            }

            // return false;
            return(base.ProcessDialogKey(keyData));  // 2017/3/12
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Blue;

            Console.Write(@"
___________.__             ________                          __      _____              __________                __          
\__    ___/|  |__   ____   \_____  \  __ __   ____   _______/  |_  _/ ____\___________  \______   \_____    _____/  |_  ______
  |    |   |  |  \_/ __ \   /  / \  \|  |  \_/ __ \ /  ___/\   __\ \   __\/  _ \_  __ \  |     ___/\__  \  /    \   __\/  ___/
  |    |   |   Y  \  ___/  /   \_/.  \  |  /\  ___/ \___ \  |  |    |  | (  <_> )  | \/  |    |     / __ \|   |  \  |  \___ \ 
  |____|   |___|  /\___  > \_____\ \_/____/  \___  >____  > |__|    |__|  \____/|__|     |____|    (____  /___|  /__| /____  >
                \/     \/         \__>           \/     \/                                              \/     \/          \/ 

       ");



            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            DelayWrite("It is 8:00 am. You have a very important interview at " +
                       "10:00 am for a job that you've been trying to get for three years!");
            DelayWrite("You haven't gotten much sleep all night due to high levels of excitement. " +
                       "Would you like to keep sleeping? yes/no:");
            string userSays = Console.ReadLine().ToLower();

            if (userSays == "yes")
            {
                DelayWrite("I must warn you, going back to sleep now highly increases your" +
                           " chances of oversleeping and missing your interview." +
                           "Are you sure you want to keep sleeping? Duh/no:");
            }
            Console.ForegroundColor = ConsoleColor.Green;
            string keepSleep = Console.ReadLine().ToLower();


            if (keepSleep == "duh")
            {
                DelayWrite("You Overslept!");
                Console.Beep();
            }


            else if (keepSleep == "no")
            {
                DelayWrite("Great! Let's get our day started then! I'll give you some time to wash yourself," +
                           "eat breakfast, and grab a cup of coffee");
            }
            else if (userSays == "no")
            {
                DelayWrite("I'm glad you're up! I'll give you some time to wash yourself, eat breakfast," +
                           " and grab a cup of coffee.");
            }


            Console.WriteLine();
            DelayWrite("Alright! Now that you're all cleaned up, let's get your outfit ready. I've already chosen a pantsuit for you to wear.");
            Console.WriteLine();
            DelayWrite("Uh-oh! It looks like your pants are missing. You've only got thirty minutes left to get dressed!");
            Thread.Sleep(200);
            Console.WriteLine();
            Thread.Sleep(200);
            DelayWrite("How about this? I might know where your pants are. If you can answer this joke correctly, I'll help you find them. Ready? yes/no");
            Console.WriteLine();
            string readySays = Console.ReadLine().ToLower();

            if (readySays == "yes")
            {
                DelayWrite("Awesome! Think very carefully about your answer, ok?");
                Console.WriteLine();
                DelayWrite("Ok. Here's the joke: If I have just won the lottery for a million dollars " +
                           "and I decide to donate a quarter of it to charity, how much do I have left?");
            }
            else if (readySays == "no")
            {
                DelayWrite("Whelp! You're not getting any help finding your pants! Good luck making it to your interview.");
            }
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine();
            string answer = Console.ReadLine().ToLower();

            if (answer == "999,999.75")
            {
                DelayWrite("You're very clever! You win. Here are your pants. Good luck on your interview.");
            }
            else
            {
                DelayWrite("You lose! Good luck finding your pants!");
            }
        }
Exemplo n.º 26
0
        // 按下键
        protected override void OnKeyDown(KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Tab:
            {
                if (Control.ModifierKeys == Keys.Shift)
                {
                    if (this.nIndex != 0)
                    {
                        fixedFieldCtrl.SwitchFocus(this.nIndex - 1,
                                                   CaretPosition.FirstChar);
                        e.Handled = true;
                    }
                }
                else
                {
                    if (this.nIndex < fixedFieldCtrl.LineCount - 1)
                    {
                        fixedFieldCtrl.SwitchFocus(this.nIndex + 1,
                                                   CaretPosition.FirstChar);
                        e.Handled = true;
                    }
                }
            }
            break;

            case Keys.Up:
            {
                if (this.nIndex != 0)
                {
                    fixedFieldCtrl.SwitchFocus(this.nIndex - 1,
                                               CaretPosition.FirstChar);
                    e.Handled = true;
                }
            }
            break;

            case Keys.Down:
            {
                if (this.nIndex < fixedFieldCtrl.LineCount - 1)
                {
                    fixedFieldCtrl.SwitchFocus(this.nIndex + 1,
                                               CaretPosition.FirstChar);
                    e.Handled = true;
                }
            }
            break;

            case Keys.Left:
            {
                if (this.SelectionStart != 0)
                {
                    break;
                }

                if (this.nIndex != 0)
                {
                    fixedFieldCtrl.SwitchFocus(this.nIndex - 1,
                                               CaretPosition.LastChar);
                    e.Handled = true;
                }
            }
            break;

            case Keys.Right:        // 右方向键
            {
                if (this.SelectionStart < this.MaxLength - 1)
                {
                    break;
                }

                if (this.nIndex < fixedFieldCtrl.LineCount - 1)
                {
                    fixedFieldCtrl.SwitchFocus(this.nIndex + 1,
                                               CaretPosition.FirstChar);
                    e.Handled = true;
                }
            }
            break;

            case Keys.End:
            {
            }
            break;

            case Keys.Home:
            {
            }
            break;

            case Keys.PageUp:
            {
            }
            break;

            case Keys.PageDown:
            {
            }
            break;

            case Keys.Insert:
            {
            }
            break;

            case Keys.Delete:
            {
                // 禁止Delete键的作用 2008/5/27
                Console.Beep();
                e.Handled = true;
            }
            break;

            case Keys.Back:
            {
                /* 不知这里为什么不管用
                 * // 禁止Backspace键的作用 2008/7/4
                 * Console.Beep();
                 * e.Handled = true;
                 * return;
                 * */
            }
            break;

            default:
                break;
            }

            base.OnKeyDown(e);
        }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            // Configuración de la pantalla
            Console.SetWindowPosition(0, 0);
            Console.SetWindowSize(Console.LargestWindowWidth / 2, Console.LargestWindowHeight - 2);

            // Nombre del alumno
            Console.Title = "Ruhl.Paula.2C";

            Estacionamiento estacionamiento = new Estacionamiento(6);

            Moto      c1 = new Moto(Vehiculo.EMarca.BMW, "ASD012", ConsoleColor.Black);
            Moto      c2 = new Moto(Vehiculo.EMarca.Honda, "ASD913", ConsoleColor.Red);
            Automovil m1 = new Automovil(Vehiculo.EMarca.Toyota, "HJK789", ConsoleColor.White);
            Automovil m2 = new Automovil(Vehiculo.EMarca.Chevrolet, "IOP852", ConsoleColor.Blue, Automovil.ETipo.Sedan);
            Camioneta a1 = new Camioneta(Vehiculo.EMarca.Ford, "QWE968", ConsoleColor.Gray);
            Camioneta a2 = new Camioneta(Vehiculo.EMarca.Renault, "TYU426", ConsoleColor.DarkBlue);
            Camioneta a3 = new Camioneta(Vehiculo.EMarca.BMW, "IOP852", ConsoleColor.Green);
            Camioneta a4 = new Camioneta(Vehiculo.EMarca.BMW, "TRE321", ConsoleColor.Green);

            // Agrego 8 ítems (los últimos 2 no deberían poder agregarse ni el m1 repetido) y muestro
            estacionamiento += c1;
            estacionamiento += c2;
            estacionamiento += m1;
            estacionamiento += m1;
            estacionamiento += m2;
            estacionamiento += a1;
            estacionamiento += a2;
            estacionamiento += a3;
            estacionamiento += a4;

            Console.WriteLine(estacionamiento.ToString());
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.ReadKey();
            Console.Clear();

            // Quito 2 items y muestro
            estacionamiento -= c1;
            estacionamiento -= new Moto(Vehiculo.EMarca.Honda, "ASD913", ConsoleColor.Red);

            Console.WriteLine(estacionamiento.ToString());
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.ReadKey();
            Console.Clear();

            // Vuelvo a agregar c2
            estacionamiento += c2;

            // Muestro solo Moto
            Console.WriteLine(Estacionamiento.Mostrar(estacionamiento, Estacionamiento.ETipo.Moto));
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.Beep();
            Console.Clear();

            // Muestro solo Automovil
            Console.WriteLine(Estacionamiento.Mostrar(estacionamiento, Estacionamiento.ETipo.Automovil));
            Console.WriteLine("<-----------PRESIONE UNA TECLA PARA CONTINUAR----------->");
            Console.ReadKey();
            Console.Clear();

            // Muestro solo Camioneta
            Console.WriteLine(Estacionamiento.Mostrar(estacionamiento, Estacionamiento.ETipo.Camioneta));
            Console.WriteLine("<-------------PRESIONE UNA TECLA PARA SALIR------------->");
            Console.ReadKey();
        }
Exemplo n.º 28
0
        public RoboWar()
        {
            Console.WriteLine("Robo war is alive!");

            ListaOrdem.oReturn = new List<Ordem>();
            try
            {
                api = new APIWrapper(Constantes.NOME_ROBO_WAR);

                resgatarOrderListLocal();
                //api.cancelarTodasOrdensPendentes();

                monitorarOrdens();
            }
            catch (Exception aException)
            {
                Console.WriteLine(aException.Message);
                Console.Beep(); Console.Beep(); Console.Beep(); Console.Beep(); Console.Beep(); Console.Beep(); Console.Beep(); Console.Beep(); Console.Beep(); Console.Beep();
                Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FALHA INESPERADA !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                System.Threading.Thread.Sleep(30000);
                Console.Beep();
                RoboWar robo = new RoboWar();
            }
        }
        //user actions --MONEY TRANSACTIONs
        public void usermenu(string accountno, string password)
        {
            heading();

            Console.WriteLine("\n\n\n\t\t\t\t\t\t  Login Successful!!!");
            Console.WriteLine("\t\t\t\t\t\t------------------------");

            bool flag = true;

            while (flag)
            {
                Console.Clear();
                heading();
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.WriteLine("\n\n\n\t\t\t\t\t\t\tCUSTOMER");
                Console.WriteLine("\n\t\t\t\t\t\t  1. Deposit Money \n\t\t\t\t\t\t  2. WithDraw Money \n\t\t\t\t\t\t  3. Transfer Money \n\t\t\t\t\t\t  4. Interest Amount \n\t\t\t\t\t\t  5. View Balance \n\t\t\t\t\t\t  6. Update Password \n\t\t\t\t\t\t  7. LOG OUT");
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("\n\t\t\t\t\t\t Enter Your Choice :");
                Console.SetCursorPosition(Console.CursorLeft + 60, Console.CursorTop);
                int choice = int.Parse(Console.ReadLine());
                try
                {
                    switch (choice)
                    {
                    case 1:
                        Console.ForegroundColor = ConsoleColor.DarkBlue;
                        Console.WriteLine("\t\t\tEnter Amount You Want to Deposit :");
                        Console.SetCursorPosition(Console.CursorLeft + 24, Console.CursorTop);

                        Console.ForegroundColor = ConsoleColor.Black;
                        double damount = double.Parse(Console.ReadLine());
                        string bal     = bmt.b_deposit(damount, accountno);
                        Console.WriteLine(bal);

                        Console.WriteLine("\nPress any key to go back");
                        Console.ReadKey();
                        break;

                    case 2:
                        Console.ForegroundColor = ConsoleColor.DarkBlue;
                        Console.WriteLine("\t\t\tEnter Amount You Want to Withdraw :");
                        Console.SetCursorPosition(Console.CursorLeft + 24, Console.CursorTop);

                        Console.ForegroundColor = ConsoleColor.Black;
                        double wamount = double.Parse(Console.ReadLine());
                        string bal2    = bmt.b_withdraw(wamount, accountno);
                        Console.WriteLine(bal2);

                        Console.WriteLine("\nPress any key to go back");
                        Console.ReadKey();
                        break;

                    case 3:
                        Console.ForegroundColor = ConsoleColor.DarkBlue;
                        Console.WriteLine("\t\t\tEnter Account number to which you want to transfer money");
                        Console.SetCursorPosition(Console.CursorLeft + 60, Console.CursorTop);

                        string toaccount = (Console.ReadLine());
                        Console.WriteLine("\t Enter Amount You Want to Transfer");
                        Console.ForegroundColor = ConsoleColor.Black;
                        double tamount = double.Parse(Console.ReadLine());
                        string bal3    = bmt.b_transfer(tamount, toaccount, accountno);
                        Console.WriteLine(bal3);

                        Console.WriteLine("\nPress any key to go back");
                        Console.ReadKey();
                        break;

                    case 4:
                        double interest = bi.b_ViewInterest(accountno);
                        Console.WriteLine("\n\t\t\tInterest Amount " + interest);
                        if (interest > 0)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkBlue;
                            Console.WriteLine("\n\t What do you want to do with the interest amount\n");
                            Console.WriteLine("\t  1. Withdraw \n\t  2. Add to Account Balance \n\t  3. Exit ");
                            Console.ForegroundColor = ConsoleColor.Black;
                            int iaction = int.Parse(Console.ReadLine());
                            switch (iaction)
                            {
                            case 1:
                                string bal4 = bi.b_WithdrawInterest(interest, accountno);
                                Console.WriteLine("\t Interest Amount Withdrawn \n\t  Interest Balance: 0.00 \n\t Available Balance : " + bal4);

                                Console.WriteLine("\nPress any key to go back");
                                Console.ReadKey();
                                break;

                            case 2:
                                string bal5 = bi.b_AddInterest(interest, accountno);
                                Console.WriteLine("\t Interest Amount Added to Account Balance \n\t Interest Balance: 0.00 \n\t Available Balance : " + bal5);
                                Console.WriteLine("\nPress any key to go back");
                                Console.ReadKey();
                                break;

                            case 3:
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("\nPress any key to go back");
                            Console.ReadKey();
                        }
                        break;

                    case 5:
                        double balance = bmt.b_availablebalance(accountno);
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("\n\t\t\tAvailable Balance :" + balance);
                        Console.ForegroundColor = ConsoleColor.Black;

                        Console.WriteLine("\nPress any key to go back");
                        Console.ReadKey();
                        break;

                    case 6:
passlabel:
                        Console.ForegroundColor = ConsoleColor.DarkBlue;
                        Console.WriteLine("\n\t\t\tEnter New Password");
                        Console.SetCursorPosition(Console.CursorLeft + 24, Console.CursorTop);
                        Console.ForegroundColor = ConsoleColor.Black;
                        string newpassword = (Console.ReadLine());

                        try
                        {
                            if (newpassword.Length < 6)
                            {
                                throw new DataEntryException("password length should be greater than 5");
                            }
                        }
                        catch (DataEntryException e)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkRed;
                            Console.WriteLine(e.Message);
                            Console.Beep();
                            goto passlabel;
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                            Console.Beep();
                            goto passlabel;
                        }
                        bmt.b_updatePassword(newpassword, accountno);
                        Console.WriteLine("\n\t Password Updated \n\t New Password : "******"\nPress any key to go back");
                        Console.ReadKey();
                        break;

                    case 7:
                        flag = false;
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                // Console.WriteLine("\nPress any key to go back");
                // Console.ReadKey();
            }
        }
Exemplo n.º 30
0
    static void Main()
    {
        // Declare and assign variables
        int  labyrinthSizeY = 32;   // This is size for Y of massive
        int  labyrinthSizeX = 28;   // This is size for X of massive
        int  torchLight     = 100;  // This is power of torch
        char w          = '\u2588'; // This is wall char
        char heroChar   = '@';      // This is hero char
        char e          = 'O';      // This is exit char
        int  x          = 15;       // And this is
        int  y          = 17;       // coordinates of start point
        int  xModifier  = 0;
        int  yModifier  = 0;
        int  moveCount  = 0;
        bool checkInput = false;

        char[,] labyrinthMask = // This is massive mask of labyrinth: get more from : http://www.noah.org/cgi-bin/brainmaze.py - view source, and after litle edit with notepad++ you can create mask massive!
        {
            { w, w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w },
            { w, ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   w,   ' ', w,   w },
            { w, ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w },
            { w, w,   w,   ' ', w,   ' ', w,   w,   w,   ' ', w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   ' ', w },
            { w, ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, w,   w,   ' ', w,   w,   ' ', w,   w,   w,   ' ', w,   w,   ' ', w,   w,   w,   ' ', ' ', ' ', w,   w,   ' ', w,   w,   w,   ' ', w,   w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, ' ', w,   w,   w,   ' ', w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   w,   w,   w,   w },
            { w, ' ', w,   ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, ' ', ' ', ' ', w,   w,   w,   ' ', w,   w,   w,   ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   w,   w,   ' ', w,   w,   ' ', w,   w },
            { w, ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w },
            { w, ' ', w,   w,   w,   ' ', w,   w,   w,   w,   w,   ' ', ' ', ' ', w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   ' ', w,   w,   w },
            { w, ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, ' ', w,   ' ', w,   ' ', w,   ' ', w,   w,   w,   ' ', w,   ' ', w,   w,   w,   w,   ' ', w,   w,   ' ', w,   ' ', w,   w,   ' ', w,   w },
            { w, ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', w,   ' ', ' ', ' ', ' ', ' ', w },
            { w, w,   w,   w,   w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   w,   w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w },
            { w, w,   ' ', w,   w,   w,   ' ', w,   w,   w,   ' ', w,   w,   w,   ' ', w,   w,   ' ', ' ', ' ', w,   w,   ' ', w,   w,   ' ', w,   w,   w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, w,   w,   ' ', w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, ' ', w,   w,   w,   w,   w,   ' ', w,   ' ', w,   ' ', w,   w,   w,   ' ', w,   w,   ' ', w,   w,   w,   ' ', w,   w,   ' ', w,   w,   w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w },
            { w, w,   w,   w,   w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w },
            { w, ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', w,   ' ', ' ', ' ', w },
            { w, ' ', w,   ' ', ' ', ' ', w,   ' ', w,   w,   ' ', w,   w,   w,   ' ', w,   w,   w,   ' ', w,   w,   ' ', w,   ' ', w,   w,   ' ', w,   w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, ' ', w,   w,   w,   w,   w,   ' ', w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   ' ', w,   ' ', w,   w,   w,   w,   w,   ' ', w },
            { w, ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w },
            { w, ' ', w,   w,   w,   ' ', w,   ' ', ' ', ' ', w,   ' ', w,   ' ', ' ', ' ', ' ', ' ', ' ', ' ', w,   w,   w,   ' ', w,   ' ', w,   ' ', w },
            { w, ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', ' ', ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', w,   ' ', ' ', ' ', ' ', ' ', w,   ' ', w },
            { w, e,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w,   w }
        };

        // Prepare console
        Console.SetWindowSize(labyrinthSizeX + 1, labyrinthSizeY + 10);
        Console.BufferHeight = Console.WindowHeight;
        Console.BufferWidth  = Console.WindowWidth;

        // This is for my pleasure ;)
        Console.Clear();
        Console.SetCursorPosition(((labyrinthSizeX + 1) / 2 - 13), (labyrinthSizeY + 10) / 2);
        Console.WriteLine("Stoyanov Games Present...");
        Console.ReadKey();
        Console.Clear();
        Console.SetCursorPosition(((labyrinthSizeX + 1) / 2 - 8), (labyrinthSizeY + 10) / 2);
        Console.WriteLine("The LaByRiNtH");
        Console.ReadKey();


        //Prepare game
        while (!checkInput)
        {
            Console.Clear();
            Console.SetCursorPosition(0, (labyrinthSizeY + 2) / 2);
            Console.Write("Select power of your  torch\n(level difficulty from\n1 hard to 5 easy): ");
            checkInput = int.TryParse(Console.ReadLine(), out torchLight) && torchLight > 0 && torchLight < 6;
        }

        Console.SetCursorPosition(x, y);

        // Game cycle
        while (true)
        {
            // Here make and print console output - every frame.
            Console.Clear();
            for (int a = -torchLight; a <= torchLight; a++)
            {
                for (int b = -torchLight; b <= torchLight; b++)
                {
                    if (x + a < 0 || y + b < 0 || x + a > labyrinthSizeX || y + b > labyrinthSizeY)
                    {
                        continue;
                    }
                    Console.SetCursorPosition(x + a, y + b);
                    Console.WriteLine((a == 0 && b == 0) ? heroChar : labyrinthMask[y + b, x + a]);
                }
            }

            // Here prepare control and take it from keyboard.
            xModifier = 0;
            yModifier = 0;
            Console.SetCursorPosition(0, labyrinthSizeX + 6);
            Console.WriteLine("x {0} - y {1}", x, y);
            switch (Console.ReadKey().Key)
            {
            case ConsoleKey.LeftArrow:
                xModifier = -1;
                break;

            case ConsoleKey.RightArrow:
                xModifier = 1;
                break;

            case ConsoleKey.UpArrow:
                yModifier = -1;
                break;

            case ConsoleKey.DownArrow:
                yModifier = 1;
                break;
            }

            // Counting moves.
            moveCount++;

            // Modify position and check status.
            if (labyrinthMask[y + yModifier, x + xModifier] == 'O')
            {
                break; // Welldone you find exit..
            }
            if (labyrinthMask[y + yModifier, x + xModifier] == ' ' && labyrinthMask[y + yModifier, x + xModifier] != e)
            {
                x = x + xModifier;
                y = y + yModifier;
            }
            else
            {
                Console.Beep(); // Hit wall or... exit :)
            }
        }
        // Print result
        Console.WriteLine("\nWelldone,\n You went through the maze\n for {0} moves!", moveCount);
    }