【发布时间】:2015-09-24 00:03:37
【问题描述】:
我需要实验室方面的帮助。我的老师没有告诉我们任何事情,他告诉我们要弄清楚。所以我可以使用我能得到的任何帮助。谢谢你
第 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);
}
我的距离公式是否正确,如果不是什么问题,你能帮我解决它吗?
第二步:我需要找到曼哈顿距离
// 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*/}
我真的不知道如何做第 2 步,所以我真的可以使用很多帮助,非常感谢你们
第 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*/}
顺便说一句,伙计们,我只是在基础计算机科学,所以我不能使用所有花哨的东西,所以保持基本和简单
【问题讨论】:
-
这看起来像 Java,而不是 JavaScript
-
另外,为什么要从 step2 中删除此链接? xlinux.nist.gov/dads/HTML/manhattanDistance.html
-
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 论坛......
-
上课?输入
double?Public?这是什么,Java?