?? main.java
字號:
import java.util.*;//Scanner位于util包
public class Main {
public Main() {
}
public static void main(String[] args) {
label0:
for (int i = 0;i<1;i++)
{
Global.Set();
Scanner in =new Scanner(System.in);
double x;double y;String s;
System.out.println("輸入線段的兩點(diǎn)坐標(biāo)構(gòu)造一個(gè)線段");
System.out.println("格式為: double空格double");
System.out.println("請輸入第一個(gè)端點(diǎn)的坐標(biāo):");
x = in.nextDouble();
y = in.nextDouble();
Global.line1.end1.SetX(x);
Global.line1.end1.SetY(y);
System.out.println("請輸入第二個(gè)端點(diǎn)的坐標(biāo):");
x = in.nextDouble();
y = in.nextDouble();
Global.line1.end2.SetX(x);
Global.line1.end2.SetY(y);
if (Global.line1.Check()) System.out.println("該線段位于第一象限");
else System.out.println("該線段不在第一象限");
double length = Global.line1.Length();
System.out.print("該線段的長度為");
System.out.println(length);
System.out.println("繼續(xù)比較嗎?y/n");
s = in.nextLine();
s = in.nextLine();
if (s.equals("y")) {
System.out.println("輸入線段的兩點(diǎn)坐標(biāo)構(gòu)造第二條線段");
System.out.println("格式為: double空格double");
System.out.println("請輸入第一個(gè)端點(diǎn)的坐標(biāo):");
x = in.nextDouble();
y = in.nextDouble();
Global.line2.end1.SetX(x);
Global.line2.end1.SetY(y);
System.out.println("請輸入第二個(gè)端點(diǎn)的坐標(biāo):");
x = in.nextDouble();
y = in.nextDouble();
Global.line2.end2.SetX(x);
Global.line2.end2.SetY(y);
if (Global.line1.IsIntersectant(Global.line2)) System.out.println("兩線段相交");
else System.out.println("兩線段不相交");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.print("第二條線段的第一個(gè)端點(diǎn)到第一條線段的距離是:");
System.out.println(Global.line1.Distance(Global.line2.end1));
System.out.println("退出嗎?y/n");
s = in.nextLine();
s = in.nextLine();
System.out.println("");
System.out.println("");
System.out.println("");
if (s.equals("n")) {
i = -1;
continue label0;
}
else break label0;
}
else {
System.out.println("退出嗎?y/n");
s = in.nextLine();
System.out.println("");
System.out.println("");
System.out.println("");
if (s.equals("n")) {
i = -1;
System.out.println("Test");
continue label0;
}
else break label0;
}
}
System.out.println("You have reach the end.");
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -