hzbn.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 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 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 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();}}

class Point{ public Point(int x,int y) { this.x = x; this.y = y; } private int x; private int y; public float compute(Point p) { return Math.sqrt((p.x-this.x)^2-(p.y-this.y)^2); } } 距离 = new Point(3,4).compute(new Point(6,8))...

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

public class Test102 { public static void main(String[] args) { Point point = new Point(); point.printPoint(); point.moveTo(1, 3); System.out.println("--移动后--"); point.printPoint(); } } class Point { private float x; private...

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

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

public class Point { private double x; private double y; public double distance(Point p1, Point p2){ return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); }}

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