我正在为 2 个相机品牌编写界面,相机的界面不同(它们有不同的 sdk)但动作相同(缩放平移倾斜)所以我需要两个类,我不知道如何进一步解释这一点,所以我将展示和示例:
class program
{
public void main(string Brand)
{
CameraController controller;
if( Brand == "A" )
controller = new BrandACameraController();
else
controller = new BrandBCameraController();
controller.Pan(); //pan with chosen camera brand
}
}
class BrandACameraController
{
public BrandACameraController()
{
}
public void Pan()
{
//interface with brand a camera
}
public void Tilt()
{
//interface with brand a camera
}
public void Zoom()
{
//interface with brand a camera
}
}
class BrandBCameraController
{
public BrandBCameraController()
{
}
public void Pan()
{
//interface with brand b camera
}
public void Tilt()
{
//interface with brand b camera
}
public void Zoom()
{
//interface with brand b camera
}
}
我该怎么做呢?