knrt.net
当前位置:首页 >> jAvA编写程序创建一个矩形类RECtAnglE >>

jAvA编写程序创建一个矩形类RECtAnglE

所有的程序都是从MAIN方法开始一步一步往下运行,你看程序下面都是输出了。 你这样看看 public static class TestRectangle{ public static void main (String args[]){ Rectangle r1=new Rectangle(5.6,12.5); Rectangle r2=new Rectangle(2,3)...

public class Rectangle{ private int width; private int height; public Rectangle(){ this.width = 10; this.height = 10; } public Rectangle(int width, int height){ this.width = width; this.height = height; } public int area(){ ret...

public class Rectangle { private double width; private double height; public Rectangle(double w,double h){ this.width = d; this.height = h; } publict double getArea(){ return width * height; } }

说明 1。颜色题目没初始化,我定义为“black” 2。 测试函数具体没说测试什么,以及长宽没初始化数值,故代码中只调用toString()方法,具体自己改写 public class Test { public static void main(String[] args) { Rectangle r1 = new Rectangle(...

package com.jihe;public class Rectangle {private double width = 1.0;private double height = 1.0;Rectangle() {}Rectangle(double width, double height) {this.width = width;this.height = height;}public double getPerimeter() {return...

public class Rectangle{ private double width, height; public Rectangle() { this(0, 0); } public Rectangle(double width, double height) { this.width = width; this.height = height; } public double getCurve() { return 2.0f * (widt...

class Point{ protected: double x; double y; public: Point(double a,double b){x=a;y=b;} Point(){x=0.0;y=0.0;} double GetX(){return x;} double GetY(){return y;} }; class Rect{ protected: Point p1; Point p2;//p1是左下角,p2是右上...

class Rectangle {private double width;private double height;public Rectangle(double width, double height) {this.width = width;this.height = height;}public double getC() {return (width + height) * 2;}public double getS() {return...

需要用图形做么? 以下为代码 不知道可否... public class Rectangle { /** * @param args */ private double width=1; private double height=1; private String color="white"; public Rectangle() { } public String getColor() { return col...

class Rectangle{ double x1, y1, x2, y2; Rectangle(){ this(0,0,0,0); } Rectangle(double x1, double y1, double x2, double y2){ this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } double getArea(){ return Math.abs((x1-x2)*(y...

网站首页 | 网站地图
All rights reserved Powered by www.knrt.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com