コード例 #1
0
ファイル: AddressBook.cs プロジェクト: Rabidgeek/CIS23
 public void Add(Person person)
 {
     foreach (Person p in Book)
     {
         if (p.GetID == person.GetID)
         {
             return;
         }
     }
     Book.Add(person);
 }
コード例 #2
0
ファイル: AddressBookTester.cs プロジェクト: Rabidgeek/CIS23
        public static void Main()
        {
            AddressBook book = new AddressBook();
            Person me = new Person("Ragsdale", "Jesse");
            Person dog = new Person("Raku", "Harlequin");
            Person meg = new Person("Malzkuhn", "Megan");

            Console.WriteLine("Testing the address book:");
            book.Add(me);
            book.Add(dog);
            book.Add(meg);
            Console.WriteLine("using book.Add():\n");
            Console.WriteLine("My fist address book entry shows:\n\t{0}", book[0]);
            Console.WriteLine("Also, I do have:\n\t{0}\n\t{1}", book[1], book[2]);
            Console.WriteLine("\nusing book.Delete():\n");
            Console.WriteLine("Whoops, let me delete the dog...");
            book.Delete(dog);
            Console.WriteLine("Now the second listing shows:\n\t{0}", book[1]);
            Console.WriteLine("\nusing book.Search()\n\nNow find me:\n\t{0}", book.Search("Jesse"));
            Console.WriteLine("\nusing book.Delete()");
            book.Delete(me);
            Console.WriteLine("Now the only listing is:\n\t{0}", book[0]);
            Console.WriteLine("\nCan we add Megan again?");

            try
            {
                book.Add(meg);
                Console.WriteLine("Yep! added again!\n\t{0}", book[1]);
            }
            catch (Exception e)
            {
                Console.WriteLine("Oh no, don't be silly!");
            }

            Console.WriteLine("\nusing book.Search()\nFind Megan by her id number:\n\t{0}", book.Search(meg.GetID));

            Console.ReadKey();
        }
コード例 #3
0
ファイル: PersonTester.cs プロジェクト: Rabidgeek/CIS23
        public static void Main()
        {
            Person J = new Person("Ragsdale", "Jesse");
            Person M = new Person("Malzkuhn", "Megan");

            Console.WriteLine("Testing Person(s):");
            Console.WriteLine("Using ToString: " + J);
            Console.WriteLine("Using ToString: " + M);
            Console.WriteLine();
            Console.WriteLine(J.GetFirst + " and " + M.GetFirst + " have been together over 5 years!");
            Console.WriteLine();
            J.GetFirst = "Mr. " + J.FirstName();
            J.GetLast = "Rags";
            Console.WriteLine("Adding 'Mr.' to Jesse's first name: " + J.GetFirst);
            Console.WriteLine("Changing Jesse's last name to Rags: " + J.GetLast);
            Console.WriteLine();
            Console.WriteLine("Using GetFirst and GetLast together: " + J.GetFirst + " " + J.GetLast);
            Console.WriteLine("Using GetFull: " + J.GetFull);
            Console.WriteLine("Using FullName(): " + J.FullName());
            Console.WriteLine("My ID is still.... " + J.GetID);

            Console.ReadKey();
        }
コード例 #4
0
ファイル: AddressBook.cs プロジェクト: Rabidgeek/CIS23
 public void Delete(Person person)
 {
     Book.Remove(person);
 }