我正在编写的程序有问题——这是一个 APCS A 类,所以有一个 APCS.lib——它包括程序中使用的 DrawingTool 类。我遇到了 import java.awt.Color 语句的问题:
有一个为整个程序执行的驱动程序,但我的问题是在 import java.awt.Color; 和第 33 行-pencil.SetColor(Color, red); . 不确定我的 drjava 没有检测到 java.awt.color 导入并且仍然给我一个“找不到符号/变量错误”。程序画了一栋房子。
//Name£∫ Allen Li
//Date: Monday, September 9th, 2013
//Purpose: Using apcslib to draw a house on with a piece of paper and pencil.
import apcslib.*;
import java.awt.Color;
public class DrawHouse{
private DrawingTool pencil;
private SketchPad paper;
/**
* Basic constructor for DrawHouse.
* Instantiates paper and pencil to basic
* values.
*/
public DrawHouse(){
paper = new SketchPad(300, 400);
pencil = new DrawingTool(paper);
}
/**
* The draw method for the DrawHouse class.
* This method will run all of the
* commands necessary to draw the house.
*
*/
public void draw(){
// draw the main house
pencil.setWidth(3);
pencil.setColor(Color, red);
pencil.down();
pencil.move(-100,0);
pencil.move(-100,100);
pencil.move(100,100);
pencil.move(100,0);
pencil.move(0,0);
//door
pencil.up();
pencil.move(-20,0);
pencil.down();
pencil.move(-20,50);
pencil.move(20,50);
pencil.move(20,0);
//roof
pencil.up();
pencil.move(-100,100);
pencil.down();
pencil.move(0,150);
pencil.move(100,100);
//window left
pencil.up();
pencil.move(-70, 60);
pencil.down();
pencil.move(-40, 60);
pencil.move(-40, 90);
pencil.move(-70, 90);
pencil.move(-70, 60);
//window right
pencil.up();
pencil.move(70,60);
pencil.down();
pencil.move(40,60);
pencil.move(40,90);
pencil.move(70,90);
pencil.move(70,60);
pencil.up();
}
}