软题库 移动APP 扫码下载APP 随时随地移动学习 培训课程
当前位置:信管网 >> 在线考试中心 >> 信息系统项目管理师题库 >> 试题查看
试卷名称 2018年上半年程序员考试下午真题试题(案例分析)
考试中心《2018年上半年程序员考试下午真题试题(案例分析)》在线考试
试卷年份2018年上半年
试题题型【分析简答题】
试题内容

阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。
【说明】
以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。

【Java代码】
interface DrawCircle { //绘制圆形
public (1);
}

class RedCircle implements DrawCircle {//绘制红色圆形
 public void drawCircle(int radius,int x, int y){
 System.out.println("Drawing Circle[red,radius:" + radius + ",x:" + x + ",y:" +y+ "]");
 }
}

class GreenCircle implements DrawCircle {//绘制绿色圆形
public void drawCircle(int radius, int x, int y) {
System.out.println("Drawing Circle[green,radius:" +radius+ ",x: " +x+ ",y: " +y+ "]");
}
}
abstract class Shape {//形状
 protected(2) ;
 public Shape(DrawCircle drawCircle) {
 this.drawCircle = drawCircle;
}
public abstract void draw();
}

class Circle extends Shape {//圆形
 private int x,y,radius;
 public Circle(int x,int y,int radius,DrawCircle drawCircle) {
 (3) ;
this.x = x;
this.y = y;
this.radius = radius;
 }

 public void draw() {
drawCircle. (4);
 }
}

public class DrawCircleMain {
public static void main(String[] args) {
Shape redCircle=new Circle( 100,100,10,(5));//绘制红色圆形
Shape greenCircle=new Circle(200,200,10,(6) );//绘制绿色圆形

redCircle.draw();
greenCircle.draw();
 }
}


相关试题

推荐文章
合作网站内容