按要求编写一个Java应用程序: (1)定义一个类,描述一个矩形,包含有长、宽两种属性和计算面积方法。 (2)编写一个类,继承自矩形类,同时该类描述长方体,具有长、宽、高属
public class Juxing { int width; int length; public Juxing(int width, int length) { super(); this.width = width; this.length = length; } int GetArea(){ return length*width; } } public class Changfangxing extends Juxing{ int height; public Changfangxing(int width, int length, int height) { super(width, length); this.height = height; } int GetV(){ return length*width*height; } } public class Test7 { public static void main(String[] args) { Changfangxing myChangfangxing = new Changfangxing(13 ,20, 12); System.out.println(myChangfangxing.GetArea()); System.out.println(myChangfangxing.GetV()); } }