return width*high;//返回长方形的面积 } } //下面测试类可以单独写 class RectaTest { public static void main(String[] args) { Rectangle r = new Rectangle(23,10);//给width ,high赋值 System.out.println(r...
int Width;int Height;};Rectangle::Rectangle(int left,int bottom,int right,int top){ itsLeft=left;itsBottom=bottom;itsRight=right;itsTop=top;} int Rectangle::GetArea(){ Width=abs(itsRight-itsLeft);Height=...
class Rectangle { private:double Length;double Width;public:Rectangle(){Length=1;Width=1;} Rectangle(double len, double w){Length=len;Width=w;} double Perimeter(){return 2*(Length+Width);} double Area(){...
include <iostream.h> class Figure { public:virtual double getArea()=0;virtual double getPerim()=0;};class Rectangle:public Figure { double a,b;public:double getArea();double getPerim();Rectangle(double x=...
include<iostream> using namespace std;class Rectangle{ private:double width,height;public:double getwidth() { return width;} public:void setLength(double width) { //名字还是统一为setWidth比较好?this.width = ...
public class Rectangle { private double width=1;private double height=1;//这个颜色你可以不用,去掉即可,同时也去掉get,set方法 private String color="white";//无参构造器 public Rectangle(){} //有参构造器 publ...
public class Rectangle { public double lenght;public double width;public Rectangle(double _length, double _width){ this.lenght = _length;this.width = _width;} public double area(){ return this.width * this...
Rectangle rectangle=new Rectangle();rectangle.setLength(5.5);rectangle.setWidth(6.6);System.out.println("周长为:"+rectangle.showPerimeter());System.out.println("面积为:"+rectangle.showArea());} } 参考...
public class Rectangle { double width;double height;string color;public void setWidth(double width) { this.width = width;} public void setHeight(double height) { this.height = height;} public void setColor(...
public class Rectangle{ private double width, height; public Rectangle() { this(0, 0); } public Rectangle(double width, double height) { this.width = width; this.height = height...