VM中桥接、NAT、仅主机模式区别

mark一下:https://www.linuxidc.com/Linux/2016-09/135521.htm

当然,这是一个常见的设计模式,Java实现桥接模式的代码示例如下: ``` interface DrawAPI { public void drawCircle(int radius, int x, int y); } class RedCircle implements DrawAPI { public void drawCircle(int radius, int x, int y) { System.out.println("画红色圆形,半径为 " + radius + ", x 坐标为 " + x + ", y 坐标为 " + y); } } class GreenCircle implements DrawAPI { public void drawCircle(int radius, int x, int y) { System.out.println("画绿色圆形,半径为 " + radius + ", x 坐标为 " + x + ", y 坐标为 " + y); } } abstract class Shape { protected DrawAPI drawAPI; protected Shape(DrawAPI drawAPI){ this.drawAPI = drawAPI; } public abstract void draw(); } class Circle extends Shape { private int x, y, radius; public Circle(int x, int y, int radius, DrawAPI drawAPI) { super(drawAPI); this.x = x; this.y = y; this.radius = radius; } public void draw() { drawAPI.drawCircle(radius,x,y); } } public class BridgePatternDemo { public static void main(String[] args) { Shape redCircle = new Circle(100,100, 10, new RedCircle()); Shape greenCircle = new Circle(100,100, 10, new GreenCircle()); redCircle.draw(); greenCircle.draw(); } } ``` 这个示例演示了一个银行展示的可能性。在这种情况下,被称为“对象”和“product”提供的不同角色,Shape是“抽象的对象”,而DrawAPI是使用在“实现的对象”。 BridgePatternDemo类是使用Shape和DrawAPI类的示例。 通过使用具有通用接口的导管,以及在运行时根据需要替换导管,Bridge模式将两个实体分开,因此可以相互独立地进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值