![]() ![]() Instead, you can create new bank account types that inherit methods and data from the BankAccount class created in the preceding tutorial. Any changes would be copied across all the affected classes. That technique would work in the short term, but it would be more work over time. You could copy that code, rename the classes, and make modifications. It can be refilled once at the start of each month.Īll of these different accounts are similar to BankAccount class defined in the earlier tutorial. A pre-paid gift card account that starts with a single deposit, and only can be paid off.A line of credit that can have a negative balance, but when there's a balance, there's an interest charge each month.An interest earning account that accrues interest at the end of each month.Over time, needs change, and related account types are requested: ![]() It works great in the situation where there is only one bank account type. Create different types of accountsĪfter building this program, you get requests to add features to it. You'll also add features to the BankAccount class, taking advantage of the abstraction and encapsulation techniques you learned in the preceding tutorial. In this tutorial, you'll extend that application to make use of inheritance and polymorphism to add new features. Both the BankAccount and Transaction classes provide encapsulation of the components needed to describe those concepts in code. You could modify its implementation without affecting any of the code that used the BankAccount class. The BankAccount class provided an abstraction for the concept of a bank account. In the preceding tutorial, introduction to classes you saw both abstraction and encapsulation. Polymorphism Ability to implement inherited properties or methods in different ways across multiple abstractions.Inheritance Ability to create new abstractions based on existing abstractions.Encapsulation Hiding the internal state and functionality of an object and only allowing access through a public set of functions.Abstraction Modeling the relevant attributes and interactions of entities as classes to define an abstract representation of a system.The four basic principles of object-oriented programming are: C# is an object-oriented programming language.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |