class Program
{
static void Main(string[] args)
{
//1、创建一个名称为Vehicle的接口,在接口中添加两个带有一个参数的方法start()和stop()。
// //在两个名称分别为Bike和Bus的类中实现Vehicle接口。
// //创建一个名称为interfaceDemo的类,在interfaceDemo的main()方法中创建Bike和Bus对象,并访问start()和stop()方法。
//Bike bike = new Bike();
//Bus bus = new Bus();
//2、设计一张抽象的门Door类,那么对于这张门来说,就应该拥有所有门的共性,开门openDoor()和关门closeDoor();
//然后对门进行另外的功能设计,防盗--theftproof()、防水--waterproof()、防弹--bulletproof()、防火、防锈……
//要求:利用继承、抽象类、接口的知识设计该门
IDoors door = new NewDoors();
Console.ReadKey();
}
}
class Bike:IVechicle
{
public Bike()
{
this.start();
this.stop();
}
public void start()
{
//throw new NotImplementedException();
Console.WriteLine("Bike 开动了!");
}
public void stop()
{
// throw new NotImplementedException();
Console.WriteLine("Bike 停止了!");
}
}
class Bus:IVechicle
{
public Bus()
{
this.start();
this.stop();
}
public void start()
{
// throw new NotImplementedException();
Console.WriteLine("Bus 开动了!");
}
public void stop()
{
// throw new NotImplementedException();
Console.WriteLine("Bus 停止了!");
}
}
abstract class Doors
{
public abstract string Theftproof
{
get;
set;
}
public abstract string Waterproof
{
get;
set;
}
public abstract string Bulletproof
{
get;
set;
}
public abstract string Fireproof
{
get;
set;
}
public abstract string Xiuproof
{
get;
set;
}
}
interface IDoors
{
void openDoor();
void closeDoor();
}
interface IVechicle
{
void start();
void stop();
}
class NewDoors:Doors,IDoors
{
private string theftproof;
private string waterproof;
private string bulletproof;
private string fireproof;
private string xiuproof;
public NewDoors()
{
this.openDoor();
this.closeDoor();
Console.WriteLine("门的属性有:{0} {1} {2} {3} {4}", Theftproof, Waterproof, Bulletproof, Fireproof, Xiuproof);
}
public override string Theftproof
{
get
{
//throw new NotImplementedException();
return "防盗";
}
set
{
theftproof = value;
}
}
public override string Waterproof
{
get
{
//throw new NotImplementedException();
return "防水";
}
set
{
// throw new NotImplementedException();
waterproof = value;
}
}
public override string Bulletproof
{
get
{
//throw new NotImplementedException();
return "防弹";
}
set
{
// throw new NotImplementedException();
bulletproof = value;
}
}
public override string Fireproof
{
get
{
//throw new NotImplementedException();
return "防火";
}
set
{
// throw new NotImplementedException();
fireproof = value;
}
}
public override string Xiuproof
{
get
{
// throw new NotImplementedException();
return "防锈";
}
set
{
// throw new NotImplementedException();
xiuproof = value;
}
}
public void openDoor()
{
// throw new NotImplementedException();
Console.WriteLine("门 打开了!");
}
public void closeDoor()
{
//throw new NotImplementedException();
Console.WriteLine("门 被关上了!");
}
}