面向对象与生活

  • 1,665 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • 还不错
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
1,665
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
97
Comments
1
Likes
5

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Billy Gao gaoxiang@5173.com *All rights reserved by 5173 1
  • 2. 1. 2. 3. *All rights reserved by 5173 2
  • 3. 1. 2. 3. 1) 2) *All rights reserved by 5173 3
  • 4. *All rights reserved by 5173 4
  • 5. … *All rights reserved by 5173 5
  • 6. … 1. 2. 1) 2) 3) *All rights reserved by 5173 6
  • 7. … *All rights reserved by 5173 7
  • 8. … *All rights reserved by 5173 7
  • 9. … *All rights reserved by 5173 7
  • 10. … “ ” *All rights reserved by 5173 7
  • 11. *All rights reserved by 5173 8
  • 12. *All rights reserved by 5173 8
  • 13. *All rights reserved by 5173 8
  • 14. … *All rights reserved by 5173 9
  • 15. … *All rights reserved by 5173 9
  • 16. … *All rights reserved by 5173 9
  • 17. … *All rights reserved by 5173 9
  • 18. *All rights reserved by 5173 10
  • 19. Polymorphism —— *All rights reserved by 5173 10
  • 20. Polymorphism —— a. overload b. override override *All rights reserved by 5173 10
  • 21. *All rights reserved by 5173 11
  • 22. public abstract class Animal { public abstract string Bark(); } public class Cat : Animal { public override string Bark() { return “ ”} } public class Dog : Animal { public override string Bark() { return “ ”} } *All rights reserved by 5173 11
  • 23. public abstract class Animal public interface IBarkable { { public abstract string Bark(); string Bark(); } } public class Cat : Animal public class Cat : IBarkable { { public override string Bark() public string Bark() { return “ ”} { return “ ”} } } public class Dog : Animal public class Dog : IBarkable { { public override string Bark() public string Bark() { return “ ”} { return “ ”} } } *All rights reserved by 5173 11
  • 24. *All rights reserved by 5173 12
  • 25. is a *All rights reserved by 5173 12
  • 26. is a is an animal. *All rights reserved by 5173 12
  • 27. is a is an animal. *All rights reserved by 5173 12
  • 28. is a is an animal. can bark. *All rights reserved by 5173 12
  • 29. is a is an animal. can bark. “ ” *All rights reserved by 5173 12
  • 30. • • • • *All rights reserved by 5173 13
  • 31. • • • • public class Cargo { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } } *All rights reserved by 5173 13
  • 32. • • • • public class Cargo public class PaymentService { { public string Id { get; set; } public void Pay(Cargo cargo) public string Name { get; set; } { public decimal Price { get; set; } // } } } *All rights reserved by 5173 13
  • 33. *All rights reserved by 5173 14
  • 34. … 2000 300. *All rights reserved by 5173 15
  • 35. *All rights reserved by 5173 16
  • 36. public class Cargo { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public enum CargoType { get; set; } // public double Discount { get; set; } // } *All rights reserved by 5173 16
  • 37. public class Cargo { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public enum CargoType { get; set; } // public double Discount { get; set; } // } public class PaymentService { public void Pay(Cargo cargo) { // CargoType Discount } } *All rights reserved by 5173 16
  • 38. … *All rights reserved by 5173 17
  • 39. … PaymentService Cargo *All rights reserved by 5173 17
  • 40. … PaymentService Cargo Cargo *All rights reserved by 5173 17
  • 41. … *All rights reserved by 5173 18
  • 42. … Cargo *All rights reserved by 5173 18
  • 43. … Cargo public interface IChargable { void Pay(); } *All rights reserved by 5173 18
  • 44. … Cargo public interface IChargable { void Pay(); } public abstract class Cargo : IChargable { public string Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } public enum CargoType { get; set; } public double Discount { get; set; } public abstract void Pay(); } *All rights reserved by 5173 18
  • 45. … *All rights reserved by 5173 19
  • 46. … Cargo *All rights reserved by 5173 19
  • 47. … Cargo public class Book : Cargo { public override void Pay() { // 8 } } *All rights reserved by 5173 19
  • 48. … Cargo public class Book : Cargo { public override void Pay() { // 8 } } public class ElecEquip : Cargo { public override void Pay() { // 2000 300 } } *All rights reserved by 5173 19
  • 49. … Cargo public class Book : Cargo { public override void Pay() { // 8 } } public class ElecEquip : Cargo { public override void Pay() { // 2000 300 } } *All rights reserved by 5173 19
  • 50. • • • • *All rights reserved by 5173 20
  • 51. • • • • *All rights reserved by 5173 20
  • 52. User.Sit(Chair  chair)   Chair.Sit(User  user)   *All rights reserved by 5173 21
  • 53. User.Sit(Chair  chair)   Chair.Sit(User  user)   *All rights reserved by 5173 21
  • 54. OOAD *All rights reserved by 5173 22
  • 55. OOAD *All rights reserved by 5173 22
  • 56. OOAD *All rights reserved by 5173 22
  • 57. OOAD *All rights reserved by 5173 22
  • 58. *All rights reserved by 5173 23
  • 59. *All rights reserved by 5173 23
  • 60. *All rights reserved by 5173 24
  • 61. *All rights reserved by 5173 24
  • 62. *All rights reserved by 5173 24
  • 63. … *All rights reserved by 5173 25
  • 64. … 24*7 *All rights reserved by 5173 25
  • 65. 1. 2. 3. *All rights reserved by 5173 26
  • 66. … *All rights reserved by 5173 27
  • 67. … Y X Z *All rights reserved by 5173 27
  • 68. … Y X Z *All rights reserved by 5173 27
  • 69. … Y X Z *All rights reserved by 5173 27
  • 70. *All rights reserved by 5173 28
  • 71. *All rights reserved by 5173 28
  • 72. *All rights reserved by 5173 28
  • 73. Hibernate *All rights reserved by 5173 28
  • 74. *All rights reserved by 5173 29
  • 75. *All rights reserved by 5173 29
  • 76. *All rights reserved by 5173 29
  • 77. *All rights reserved by 5173 29
  • 78. *All rights reserved by 5173 29
  • 79. *All rights reserved by 5173 30
  • 80. *All rights reserved by 5173 30
  • 81. *All rights reserved by 5173 30
  • 82. *All rights reserved by 5173 30
  • 83. Time *All rights reserved by 5173 31
  • 84. cargo.Pay(); Time *All rights reserved by 5173 31
  • 85. cargo.Pay(); Paying Time *All rights reserved by 5173 31
  • 86. cargo.Pay(); Paying Paid Time *All rights reserved by 5173 31
  • 87. cargo.Pay(); Paying Paid Time *All rights reserved by 5173 31
  • 88. I. C# II. C# III. *All rights reserved by 5173 32
  • 89. I. C# II. C# III. *All rights reserved by 5173 32
  • 90. I. C# II. C# III. *All rights reserved by 5173 32
  • 91. IV. *All rights reserved by 5173 33
  • 92. IV. *All rights reserved by 5173 33
  • 93. IV. *All rights reserved by 5173 33
  • 94. IV. *All rights reserved by 5173 33
  • 95. IV. Design Patterns Explained *All rights reserved by 5173 33
  • 96. *All rights reserved by 5173 34
  • 97. • *All rights reserved by 5173 34
  • 98. •  *All rights reserved by 5173 34
  • 99. •  • *All rights reserved by 5173 34
  • 100. •  •  *All rights reserved by 5173 34
  • 101. 1. 2. 3. *All rights reserved by 5173 35
  • 102. “ ” *All rights reserved by 5173 36
  • 103. “ ” *All rights reserved by 5173 36
  • 104. *All rights reserved by 5173 37
  • 105. *All rights reserved by 5173 37
  • 106. … *All rights reserved by 5173 37
  • 107. … … *All rights reserved by 5173 37
  • 108. … … *All rights reserved by 5173 37
  • 109. Level0 Level1 Level2 Level3 … *All rights reserved by 5173 38
  • 110. … *All rights reserved by 5173 39
  • 111. … *All rights reserved by 5173 39
  • 112. … … *All rights reserved by 5173 39
  • 113. … … *All rights reserved by 5173 39
  • 114. *All rights reserved by 5173 40
  • 115. a1 = F(a0); an+1 = F’(an) (n > 0); *All rights reserved by 5173 40
  • 116. a1 = F(a0); an+1 = F’(an) (n > 0); a1 = F(a0); *All rights reserved by 5173 40
  • 117. a1 = F(a0); an+1 = F’(an) (n > 0); a1 = F(a0); an+1 = F’(an) (n > 0); *All rights reserved by 5173 40
  • 118. *All rights reserved by 5173 41
  • 119. Level 0 *All rights reserved by 5173 41
  • 120. Level 0 Level 1 *All rights reserved by 5173 41
  • 121. Level 0 Level 1 Level 2 *All rights reserved by 5173 41
  • 122. Level 0 Level 1 Level 2 Object Level N *All rights reserved by 5173 41
  • 123. Level 0 Level 1 Level 2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  • 124. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  • 125. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  • 126. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  • 127. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  • 128. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 Object Level N *All rights reserved by 5173 41
  • 129. Level 0 Level 1 Level 2 Employee Manager Level N-2 Person Level N-1 OOP a1 Object Level N *All rights reserved by 5173 41
  • 130. *All rights reserved by 5173 42