01.
public
class
Program
02.
{
03.
public
static
void
Main()
04.
{
05.
ship submarine =
new
ship();
06.
submarine.drive(15);
07.
submarine.load(
"prayoot"
);
08.
submarine.Display();
09.
}
10.
}
11.
class
car {
12.
protected
int
toldist =0;
13.
public
int
drive(
int
dist) {
14.
this
.toldist =
this
.toldist+dist;
15.
return
this
.toldist;
16.
}
17.
public
virtual
void
Display() {
18.
Console.WriteLine(
this
.toldist +
" HP"
);
19.
}
20.
}
21.
22.
class
ship : car {
23.
string
passenger;
24.
public
override
void
Display() {
25.
Console.WriteLine(
this
.toldist +
" HP"
);
26.
Console.WriteLine(
this
.passenger);
27.
}
28.
29.
public
string
load(
string
val) {
30.
this
.passenger = val;
31.
return
this
.passenger;
32.
}
33.
34.
}