コード例 #1
0
        static void Main(string[] args)
        {
            bool            exit      = false;
            int             selection = 0;
            List <Relative> relatives = new List <Relative>();

            while (!exit)
            {
                WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + ("Main Menu".Length / 2)) + "}", "Main Menu"));
                Write(
                    "\n1: Add Relative" +
                    "\n2: View Relatives alphabeticaly" +
                    "\n3: Search by Name" +
                    "\n4: Search by Month of Birth" +
                    "\n5: Exit" +
                    "\n->");
                selection = Convert.ToInt32(ReadLine());
                switch (selection)
                {
                case 1:
                    relatives.Add(Relative.addRelative());
                    break;

                case 2:
                    Relative.search(relatives);
                    break;

                case 3:
                    Relative.search(relatives, "");
                    break;

                case 4:
                    Relative.search(relatives, 00);
                    break;

                case 5:
                    WriteLine("\nGoodbye!");
                    exit = true;
                    break;

                default:
                    break;
                }
            }
        }
コード例 #2
0
        public static Relative addRelative()
        {
            Relative temp = new Relative();

            WriteLine("Please enter the first name of the Relative: ");
            temp.FirstName = ReadLine();
            WriteLine("Please enter the last name of the Relative: ");
            temp.LastName = ReadLine();
            WriteLine("Please enter the relation to you of the Relative: ");
            temp.Relation = ReadLine();
            WriteLine("Please enter the phone number of the Relative: ");
            temp.Relation = ReadLine();
            WriteLine("Please enter the month Relative was born in (e.g. 01, 02, 03... 12.): ");
            temp.BirthdayMonth = ReadLine();
            WriteLine("Please enter the day Relative was born on: ");
            temp.BirthdayDay = ReadLine();
            WriteLine("Please enter the year Relative was born in: ");
            temp.BirthdayYear = ReadLine();
            return(temp);
        }