软考真题
第20题
阅读以下说明和Java程序,填写程序中的空(1) ~(6) ,将解答写入答题纸的对应栏内。

【说明】
以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。



【Java代码】


interface DrawCircle {                  /* 绘制圆形 */
	public (1) ;
}

class RedCircleimplementsDrawCircle {   /* 绘制红色圆形 */
	public void drawCircle( intradius, int x, int y )
	{
		System.out.println( "DrawingCircle[red,radius:" + radius + ",x:" + x + ",y:" + y + "]" );
	}
}

class GreenCircleimplementsDrawCircle { /* 绘制绿色圆形 */
	public void draw Circle( intradius, int x, int y )
	{
		System.out.println( "DrawingCircle[green,radius:" + radius + ",x: " + x + ",y: " + y + "]" );
	}
}
abstract class Shape {                  /* 形状 */
	protected (2);

	public Shape( DrawCircledrawCircle )
	{
		this.drawCircle = drawCircle;
	}


	public abstract void draw();
}

class CircleextendsShape { /* 圆形 */
	private int x, y, radius;

	public Circle( int x, int y, int radius, DrawCircledrawCircle )
	{
		(3);
		this.x		= x;
		this.y		= y;
		this.radius	= radius;
	}

	publicvoiddraw()
	{
		drawCircle.(4);
	}
}

public class DrawCircleMain {
	public static void main( String[] args )
	{
		ShaperedCircle = newCircle( 100, 100, 10, (5) ) ;       /* 绘制红色圆形 */
		ShapegreenCircle = newCircle( 200, 200, 10, (6) ) ;     /* 绘制绿色圆形 */

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



【问题5.1】
第11章Java程序设计
正确答案:
你的答案:
请先在App中激活(应用市场搜“软考真题”)
知识点:
试卷:
2018年 上半年 下午试卷 案例

笔记

呃呃

请先在App中激活(应用市场搜“软考真题”)

2022-11-02


答题卡
加油