示例#1
0
        //Prints out how to use the menu system
        private static void PrintWelcomeClient()
        {
            string[] starray = new string[] { "Create a person!",
                                              "Du har kommit till huvudmenyn och kommer navigera genom att skriva in siffror för att testa olika funktioner.",
                                              "\n" };
            string s = String.Join("\n", starray);

            ValuesOfStrings.StrOut(s);
        }
示例#2
0
        //Prints out the head menu
        private static void PrintMainMenu()
        {
            string[] starray = new string[] { "Mainmeny: ",
                                              "Menu 1: Create a new person",
                                              "Menu 2: Show persons",
                                              "Menu 3: Insert new person",
                                              "Menu 0 for Quit program",
                                              "\n" };
            string s = String.Join("\n", starray);

            ValuesOfStrings.StrOut(s);
        }
示例#3
0
        static void PrintOutPerson(Person p)
        {
            string[] starray = new string[] { "\n",
                                              "" + p.GetFName + " " + p.GetLName,
                                              p.GetAge + " years old",
                                              //"\n",
                                              p.GetHeight + " m",
                                              //"\n",
                                              p.GetWeight + " Kg",
                                              //"\n"
            };
            string s = String.Join("\n", starray);

            ValuesOfStrings.StrOut(s);
        }
示例#4
0
 private static void PrintHeight()
 {
     ValuesOfStrings.StrOut("Height(Meters): ");
 }
示例#5
0
 private static void PrintWeight()
 {
     ValuesOfStrings.StrOut("Weight(Kg): ");
 }
示例#6
0
 private static void PrintAge()
 {
     ValuesOfStrings.StrOut("age: ");
 }
示例#7
0
 private static void PrintLastName()
 {
     ValuesOfStrings.StrOut("Last Name: ");
 }
示例#8
0
        //Handles the menu optoions for the program
        private static void HandleOptions(PersonHandler ph)
        //private static void HandleOptions(Person p, PersonHandler ph)
        {
            //While true, menu will be running
            bool menuActual = true;

            do
            {
                //prints out menu
                PrintMainMenu();
                //switch recives input from user and handle options chose dependent of users string input
                string x          = Console.ReadLine();
                string caseSwitch = x;
                switch (caseSwitch)
                {
                case "1":
                    string n;
                    PrintName();
                    n = Console.ReadLine();
                    //try { p.GetFName = n; }catch (Exception e) { Console.WriteLine("{0} Exception caught.", e);}

                    PrintLastName();
                    n = Console.ReadLine();
                    //try { p.GetLName = n; }catch (Exception e){Console.WriteLine("{0} Exception caught.", e);}

                    int age;
                    PrintAge();
                    n = Console.ReadLine();
                    if (ValuesOfStrings.IsStringInt(n))
                    {
                        age = ValuesOfStrings.IntParsedValue(n);
                    }
                    else
                    {
                        age = 0;
                    }                    //matar in ett default int värde för att kunna ta emot ett värde i person klassen
                    //try { p.GetAge = age; }catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); }

                    double height;
                    PrintHeight();
                    n = Console.ReadLine();
                    if (ValuesOfStrings.IsStringDouble(n))
                    {
                        height = ValuesOfStrings.DoubleParsedValue(n);
                    }
                    else
                    {
                        height = 0.0;
                    }                         //matar in ett default double värde för att kunna ta emot ett värde i person klassen
                    //try { p.GetHeight = height; }catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); }

                    double weight;
                    PrintWeight();
                    n = Console.ReadLine();
                    if (ValuesOfStrings.IsStringDouble(n))
                    {
                        weight = ValuesOfStrings.DoubleParsedValue(n);
                    }
                    else
                    {
                        weight = 0.0;
                    }                         //matar in ett default double värde för att kunna ta emot ett värde i person klassen
                    //try { p.GetWeight = weight; }catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); }

                    ValuesOfStrings.StrOut("\n" + "Thanx!");
                    //PrintOutPerson(p);
                    break;

                case "2":
                    ValuesOfStrings.StrOut("2" + "\n");
                    //PrintOutPerson(p);

                    break;

                case "3":
                    ValuesOfStrings.StrOut("3" + "\n");
                    //madePerson(p,ph);
                    break;


                case "0":
                    ValuesOfStrings.StrOut("Menu 0 for Quit");
                    menuActual = false;
                    Environment.Exit(0);
                    break;

                default:
                    ValuesOfStrings.StrOut("Wrong Input");
                    break;
                }
            } while (menuActual);
        }