SLIDE 36 36
Dog and Cat Class (4)
Dog: Toto Black, 4 legs, 0 tail Cat: Lulu White, 4 legs, 1 tail Dog: toop no color, 4 legs, 1 tail Class: Dog and Cat NoPets = 3
/ / Main here public static void Main () { DogCat a = new DogCat("Toto", "black", "hong"); DogCat b = new DogCat("Lulu", "white", "miao"); DogCat c = new DogCat(); Console.WriteLine("\ nNumber of pets are { 0} .", NumberOfPets()); Console.WriteLine("My { 0} .", a.myPrint()); Console.WriteLine("My { 0} .", b.myPrint()); Console.WriteLine("My { 0} .", c.myPrint()); a.cutTail(); a.hitByCar(1); Console.WriteLine("\ nNumber of pets are { 0} .", NumberOfPets()); Console.WriteLine("My { 0} .", a.myPrint()); Console.WriteLine("My { 0} .", b.myPrint()); Console.WriteLine("My { 0} .", c.myPrint()); Console.ReadLine(); } } 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
Dog: Toto Black, 4 legs, 1 tail Cat: Lulu White, 4 legs, 1 tail Dog: toop no color, 4 legs, 1 tail Class: Dog and Cat NoPets = 3 Dog: Toto Black, 3 legs, 0 tail