mdsk.net
当前位置:首页 >> 求大神帮忙写一下程序,用jAvA写 定义一个Point类... >>

求大神帮忙写一下程序,用jAvA写 定义一个Point类...

public class Point {private double x;private double y;// 获取距离public double getDistance(Point p) {return Math.sqrt(Math.pow(x - p.x, 2) + Math.pow(y - p.y, 2));}// 测试public static void main(String[] args) {Point p1 = new P...

public class Point{private double x;private double y;Point(){}Point(double a,double b){this.x=a;this.y=b;}public double getX(){return this.x;}public double getY(){return this.y;}public void setX(double a){this.x=a;}public void ...

public class Point { private int x; private int y; public Point(int x, int y) { this.x = x; this.y = y; } public int getX() { return x; } public void setX(int x) { this.x = x; } public int getY() { return y; } public void setY(...

public class twopoint {private int x;private int y;public void set(int a,int b){x = a;y = b;}public void get(){System.out.println("(" + x + "," + y + ")");}public twopoint(int c,int d){set(c,d);get();}}

代码就不给你打了,我给你说思路,其实是很简单的。 需要两个类,一个Point,一个Test。这两个类,是调用和被调用的关系,Point被Test调用。 关系说好了,就是类具体实现的问题。 Point.java 这个类近似于常说的工具类或者辅助类。这里面既然对...

如果你要画点的话,可以这样做. Graphics2D g2=(Graphics2D)g; Line2D p1=new Line2D.Double(98,48,98,48); g2.draw(p1);

实现思路就是有一个类Point,之后这个类有两个私有成员变量,之后可以通过set和get方法进行赋值和数值读取: public class Point { private String x; private String y; /** * 默认构造函数 */ public Point(){ } /** *有x和y的构造方法。 */ p...

public class Point implements Cloneable { private int x; private int y; // 不带参数的构造方法 public Point() { this(0, 0); } // 带参数的构造方法 public Point(int x, int y) { this.x = x; this.y = y; } // 拷贝方法 @Override prote...

文件MyPoint.java public class MyPoint{ public double x,y; public MyPoint(){ x = 0.0; y = 0.0; } public MyPoint(double x,double y){ this.x = x; this.y = y; } public void show(){ System.out.println("("+x+","+y+")"); } public stat...

你看看吧。我也是今天写jaca作业的时候写的,不知道行不行。searchpcc 自己修改一下: /* * Project: 空间点 * Author: searchpcc(xixi,11级,20112866) * File: TuXing.java * Instruction: 主程序 * Time: 2012-11-07 */ class Point2D{ int x;...

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