0
回答
继承GCompound无法输出图像。

更详细的资料在下方连接中。

import acm.graphics.*;
/** This class defines a GCompound that represents a train. */
public class Train extends GCompound {
/**
 * Creates a new train that contains no cars. Clients can add
 * cars at the end by calling append.
 */
 public Train() {
 /* No operations necessary */
 }
/**
 * Adds a new car to the end of the train.
 * @param car The new train car
 */
 public void append(TrainCar car) {
 double width = getWidth();
 double x = (width == 0) ? 0 : width - TrainCar.CONNECTOR;
 add(car, x, 0);
 }
}

http://www-cs-faculty.stanford.edu/~eroberts/courses/cs106a/handouts/30-graphical-structures.pdf

举报
INGQI
发帖于6年前 0回/37阅
顶部