using
System;
namespace
Demo {
internal
class
Program {
internal
enum
DriveCommand {
PETROL,
DIESEL,
CNG,
ELECTRIC
}
public
interface
IDumpable {
DriveCommand Command
{
get
;
set
;
}
void
Dump();
}
public
class
BMW : IDumpable {
private
DriveCommand _command;
private
int
_speed;
public
DriveCommand Command
{
get
{
return
_command; }
set
{ _command = value; }
}
public
BMW(
int
Speed) {
this
._speed = Speed; }
public
void
Dump()
{
Console.WriteLine(
"I AM DRIVING BMW"
);
Console.WriteLine(
"Command : "
+ _command);
if
(_command == DriveCommand.PETROL) {
Console.WriteLine(
"BMW IS NOW DRIVING ON "
+ _command
+
" WITH SPEED OF "
+ _speed.ToString()
+
" KM/HR"
+
"\n"
);
}
else
{
Console.WriteLine("BMW IS NOT COMPATIBLE TO
DRIVE ON
" + _command + "
\n");
}
}
}
public
class
TRUCK : IDumpable {
private
DriveCommand _command;
private
int
_speed;
public
DriveCommand Command
{
get
{
return
_command; }
set
{ _command = value; }
}
public
TRUCK(
int
Speed) {
this
._speed = Speed; }
public
void
Dump()
{
Console.WriteLine(
"I AM DRIVING TRUCK"
);
Console.WriteLine(
"Command : "
+ _command);
if
(_command == DriveCommand.DIESEL) {
Console.WriteLine(
"TRUCK IS NOW DRIVING ON "
+ _command
+
" WITH SPEED OF "
+ _speed.ToString()
+
" KM/HR"
+
"\n"
);
}
else
{
Console.WriteLine(
"TRUCK IS NOT COMPATIBLE TO DRIVE ON "
+ _command +
"\n"
);
}
}
}
public
class
TUCSON : IDumpable {
private
DriveCommand _command;
private
int
_speed;
public
DriveCommand Command
{
get
{
return
_command; }
set
{ _command = value; }
}
public
TUCSON(
int
Speed) {
this
._speed = Speed; }
public
void
Dump()
{
Console.WriteLine(
"I AM DRIVING TUCSON"
);
Console.WriteLine(
"Command : "
+ _command);
if
(_command == DriveCommand.PETROL
|| _command == DriveCommand.ELECTRIC) {
Console.WriteLine(
"TUCSON IS NOW DRIVING ON "
+ _command
+
" WITH SPEED OF "
+ _speed.ToString()
+
" KM/HR"
+
"\n"
);
}
else
{
Console.WriteLine("TUCSON IS NOT COMPATIBLE TO DRIVE
ON
" + _command + "
\n");
}
}
}
public
class
WAGONR : IDumpable {
private
DriveCommand _command;
private
int
_speed;
public
DriveCommand Command
{
get
{
return
_command; }
set
{ _command = value; }
}
public
WAGONR(
int
Speed) {
this
._speed = Speed; }
public
void
Dump()
{
Console.WriteLine(
"I AM DRIVING WAGONR"
);
Console.WriteLine(
"Command : "
+ _command);
if
(_command == DriveCommand.PETROL
|| _command == DriveCommand.CNG) {
Console.WriteLine(
"WAGONR IS NOW DRIVING ON "
+ _command
+
" WITH SPEED OF "
+ _speed.ToString()
+
" KM/HR"
+
"\n"
);
}
else
{
Console.WriteLine("WAGONR IS NOT COMPATIBLE TO DRIVE
ON
" + _command + "
\n");
}
}
}
static
void
Main(
string
[] args)
{
IDumpable Car =
new
BMW(90);
Car.Command = DriveCommand.PETROL;
Car.Dump();
Car.Command = DriveCommand.DIESEL;
Car.Dump();
Car =
new
TRUCK(100);
Car.Command = DriveCommand.DIESEL;
Car.Dump();
Car =
new
TUCSON(80);
Car.Command = DriveCommand.PETROL;
Car.Dump();
Car.Command = DriveCommand.ELECTRIC;
Car.Dump();
Car =
new
WAGONR(50);
Car.Command = DriveCommand.CNG;
Car.Dump();
Console.Read();
}
}
}