コード例 #1
0
        static void Main(string[] args)
        {
            list mylist = new list();



            for (int i = 0; i < 5; i++)

            {
                ListExercises1 L1 = new ListExercises1();

                Console.WriteLine("Enter Name to add a person : ");
                L1.setName(Console.ReadLine());

                if (mylist.AddPerson(L1) == true)
                {
                    Console.WriteLine("Person has been added");
                }
                else
                {
                    Console.WriteLine("Coach full");

                    Console.WriteLine(mylist.getNumOfPassengers());
                }
            }

            Console.WriteLine("Please enter the name you would like to find and remove ");
            string nameofperson = Console.ReadLine();

            Console.WriteLine(nameofperson + "There position is " + mylist.GetPositionByName(nameofperson));



            Console.ReadLine();
        }
コード例 #2
0
        ///private int position = 0;

        public bool AddPerson(ListExercises1 theListExercises1)
        {
            if (nextFreeLocation >= contents.Length)
            {
                return(false);
            }
            contents[nextFreeLocation] = theListExercises1;
            nextFreeLocation++;
            return(true);
        }