using System;
namespace Oop6
{
class Program
{
static void Main(string[] args)
{
Vehicle Civic = new Vehicle(4,200,"Dinkeee");
if (Civic is IDrivable)
{
Civic.Move();
Civic.Stop();
}
else
{
Console.WriteLine("The {0} Cant be driven", Civic.Brand);
}
Console.ReadKey();
}
}
interface IDrivable
{
int Wheels { get; set;}
double Speed { get; set; }
void Move();
void Stop();
}
class Vehicle:IDrivable
{
public string Brand { get; set;}
public int Wheels{get; set;}
public double Speed{get; set;}
public Vehicle(int wheels=0,double speed=0,string brand="No Brand")
{
Brand = brand;
Wheels = wheels;
Speed = speed;
}
public void Move() {
Console.WriteLine("The {0} moves at {1} MPH",Brand,Speed);
}
public void Stop() {
Console.WriteLine("The {0} stoped", Brand);
Speed = 0;
}
}
}
namespace Oop6
{
class Program
{
static void Main(string[] args)
{
Vehicle Civic = new Vehicle(4,200,"Dinkeee");
if (Civic is IDrivable)
{
Civic.Move();
Civic.Stop();
}
else
{
Console.WriteLine("The {0} Cant be driven", Civic.Brand);
}
Console.ReadKey();
}
}
interface IDrivable
{
int Wheels { get; set;}
double Speed { get; set; }
void Move();
void Stop();
}
class Vehicle:IDrivable
{
public string Brand { get; set;}
public int Wheels{get; set;}
public double Speed{get; set;}
public Vehicle(int wheels=0,double speed=0,string brand="No Brand")
{
Brand = brand;
Wheels = wheels;
Speed = speed;
}
public void Move() {
Console.WriteLine("The {0} moves at {1} MPH",Brand,Speed);
}
public void Stop() {
Console.WriteLine("The {0} stoped", Brand);
Speed = 0;
}
}
}
Comments
Post a Comment