Java 距离公式

Java 距离公式,java,formula,distance,Java,Formula,Distance,我需要一个实验室的帮助。我的老师什么都没告诉我们,他让我们去弄清楚。所以我可以利用我能得到的任何帮助。多谢各位 步骤1:包括我的距离公式在内的步骤1一切都好吗?我正在尝试将xx设置为x,将yy设置为y,所以我不知道该怎么做。你能帮我一下吗 class Point { private int x; private int y; public Point() // (0, 0)

我需要一个实验室的帮助。我的老师什么都没告诉我们,他让我们去弄清楚。所以我可以利用我能得到的任何帮助。多谢各位

步骤1:包括我的距离公式在内的步骤1一切都好吗?我正在尝试将
xx
设置为
x
,将
yy
设置为
y
,所以我不知道该怎么做。你能帮我一下吗

    class Point {
        private int x;
        private int y;

        public Point()                          // (0, 0)
        {
          x = 0;
          y = 0;
    }

        public Point(int xx, int yy)
        {  
           xx = x;
           yy = y;
    }

        public int getX()                       // return field values
        {
            return x;
    }
        public int getY()
        {
            return y;

    }

        // Use the distance formula to find the distance of this point from the origin (0,0)
        public double distanceFromOrigin()
        {
                int d = 0;


                d = Math.squrt(Math.pow(xx - x) + (Math.pow(yy - y);
}
我的距离公式好吗?如果不好的话,有什么问题吗?你能帮我解决吗

步骤2:我需要找到曼哈顿距离

// Find the "manhattan" distance between current point and other.
//  You can look at http://x...content-available-to-author-only...t.gov/dads//HTML/manhattanDistance.html for help
public double distance(Point other) 
{/*write the code for here*/}
我真的不知道如何做第二步,所以我真的需要很多帮助。非常感谢你们

步骤3:找到当前点和其他点之间的曼哈顿距离后。我需要将其更改为新值,但我不知道如何获取新值以及如何更改它。在那之后,我需要通过翻译T来转移这个点,我不知道该怎么做,所以我需要帮助

// Changes the coordinate to new values
public void setLocation(int x, int y)
{/*write the code for here*/}

//Shift the point by the translation T<x+h,y+k>
public void translate(int h, int k)
{/*write the code for here*/}
//将坐标更改为新值
公共无效设置位置(整数x,整数y)
{/*在此处编写代码*/}
//通过平移T移动该点
公共空转换(int h,int k)
{/*在此处编写代码*/}

顺便说一句,伙计们,我只懂基本的计算机科学,所以我不能使用所有花哨的东西,所以要保持基本和简单,就像托文在评论中说的那样,这看起来真的像Java而不是Javascript。这是两种不同的语言,尽管名称相似

通常看一下您的代码,会发现一些明显的错误,这让我想知道您正在使用什么IDE(集成开发环境)来编写代码。一个帮助你编写代码的适当程序会发现这些问题

就在距离原点()的距离中,您缺少:

  • 2个闭合支架
  • Math.squrt()应该是Math.sqrt()
  • 尽管已将方法返回类型设置为double,但仍不返回值

老实说,在继续之前,您可能应该首先设置一个IDE并完成一个基本的Java教程。

这看起来像Java,而不是JavaScript2,为什么要从步骤2中删除此链接
d=Math.squrt(Math.pow(xx-x)+(Math.pow(yy-y);
应该是
d=Math.sqrt(Math.pow(xx-x)+(Math.pow(yy-y))
这是sqrt而不是squrt,结尾的结束括号..顺便说一句,这是JavaScript论坛而不是JAVA。@Blindman67这不是JavaScript论坛…Class?键入
double
Public
?这是什么,JAVA?