classAConcreteDrawAPI : public DrawAPI { public: ~AConcreteDrawAPI() override {} voiddrawCircle(double x, double y, double radius)override { std::cout<<"Draw Circle with API A"<<std::endl; std::cout<<"Draw Circle at "<<x<<":"<<y<<" "<<radius<<std::endl; } };
classBConcreteDrawAPI : public DrawAPI { public: ~BConcreteDrawAPI() override {} voiddrawCircle(double x, double y, double radius)override { std::cout<<"Draw Circle with API B"<<std::endl; std::cout<<"Draw Circle at "<<x<<":"<<y<<" "<<radius<<std::endl; } };
@Override publicvoiddraw() { drawAPI.drawCircle(x, y, radius); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
publicinterfaceDrawAPI { voiddrawCircle(double x, double y, double radius); }
publicclassAConcreteDrawAPIimplementsDrawAPI { @Override publicvoiddrawCircle(double x, double y, double radius) { System.out.println("Draw Circle with API A"); System.out.println("Draw Circle at " + x + ":" + y + " " + radius); } }
publicclassBConcreteDrawAPIimplementsDrawAPI { @Override publicvoiddrawCircle(double x, double y, double radius) { System.out.println("Draw Circle with API B"); System.out.println("Draw Circle at " + x + ":" + y + " " + radius); } }