【发布时间】:2015-11-03 17:33:17
【问题描述】:
大家好,抱歉,如果这是一个常见且烦人的问题,我正在尝试创建一个父类(用于 3 个单独的类),但我真的不确定从这里去哪里。
我需要它们在 0
或者我不需要 3 个新课程,而是我可以在同一个课程中全部完成?
如果您认为我需要它,请随时添加建议。
TIA
public class Soldier {
public static void main(String args[]) {
Random random = new Random();
double max = 100; //sets the limit to 100 for the soldiers spawn
double min = 0; //sets the minimum to 0 for the soldiers spawn
double xPos = Math.random() * (max - min) - min;//for the x coordinate of the soldiers position
double yPos = Math.random() * (max - min) - min; //for the y coordinate of the soldiers position
xPos = Math.round(xPos * 10) / 10.0d; //making sure the x value is to 1dp
yPos = Math.round(yPos * 10) / 10.0d; //making sure the y value is to 1dp
System.out.println("(" + xPos + " ," + yPos + ")"); //printing out the position of the soldier (x, y)
}
}
【问题讨论】:
-
您的问题似乎至少包含 3 个问题,其中 0 个问题表达清楚足以给您一个正确的答案。您要解决的实际问题是什么?是什么让您想到了子班?
标签: java inheritance parent-child