Your English is very good so don't worry about it ;)
Lets now try to show you the meaning of each of the features you enumrated.
Picture this: you want to model various races of dogs. For our example lets consider a pitbull and a pug.
abstract class Dog {
virtual void move() {
Console.WriteLine("Run like mad");
}
virtual void talk() {
Console.WriteLine("Bark!");
}
abstract void whoAmI();
}
class Pug : Dog {
override void move() {
Console.WriteLine("Take little steps since I'm little.");
}
void whoAmI() {
Console.WriteLine("I am a pug!");
}
}
class Bulldog : Dog {
void whoAmI() {
Console.WriteLine("I am a bulldog!");
}
}
Pug and bulldog inherit from dog so they also inherit dog's methods: move, talk and whoAmI. This process is called
inheritance.
They can choose to override those methods (assuming they were defined as virtual in the parent class) like Pug did with the move method. This process is called
overriding (makes sense right?).
This structure allows the following interaction:
Pug p = new Pug();
Bulldog b = new Bulldog();
p.talk() -> "Bark!"
b.talk() -> "Bark!"
p.whoAmI() -> "I am a pug"
b.whoAmI() -> "I am a bulldog"
p.move() -> "Take little steps..."
b.move() -> "Run like mad"
Notice that we never got to define the talk methods on the Pug and Bulldog classes but since their parent class (Dog) defined it, those classes also have it. That's one of the powers of inheritance.
Another possible interaction:
Dog dog1 = new Pug();
Dog dog2 = new Bulldog();
dog1.whoAmI() -> "I am a pug"
dog2.whoAmI() -> "I am a bulldog"
Notice that we are now handling a pug and a bulldog by referring to the parent class. This is called
polymorphism (one of the many types that exist). A class can be referred to as either itself or one of the parent classes.
As for
encapsulation, it has to do with hiding the details of the implementation and the bundling of common data. Picture a Collection class. A collection can be implemented in a number of ways. The two most common are an array or a list. However, in terms of interaction, it doesn't really matter to the user what kind of implementation it uses. This could be accomplished with the following interface:
class Collection {
public int getItem(int position);
public void addItem(int position, int value);
private int[] collectionArray;
private List<int> collectionList;
}
By using the getItem and addItem functions the particular implementation of the collection doesn't matter. Notice that because collectionArray/List is private, the user is forced to use your wrapper functions!
I think that covers the basics. For more info check out wikipedia! It has an extensive explanation of each of the features.