java语言程序设计基础篇第十版第十四章练习答案
java语言程序设计基础篇第十版课后答案

第一章1.1public class Test{public static void main(String[]args){System.out.println("Welcome to Java!"); System.out.println("Welcome to Computer Science!");System.out.println("Progr amming is fun.");}}1.2public class Test{public static void main(String[]args){for(int i=0;i<=4;i++){System.out.println("Welcome to Java!");}}}1.3public class Test{public static void main(String[]args){System.out.println("]");System.out.printl n("]");System.out.println("]]");System.out.println("]]");}}public class Test{public static void main(String[]args){System.out.println("A"); System.out.println("A A");System.out.println("AAAAA");System.out.println("A A");}}public class Test{public static void main(String[]args){System.out.println("V V");System.out.println("V V");System.out.println("V V");System.out.println(" V");}}1.4public class Test{public static void main(String[]args){System.out.println("a a^2a^3");System.out.println("111");System.out.println("248");System.out.println("3 927");System.out.println("41664");}}1.5public class Test{public static void main(String[]args){System.out.println((9.5*4.5-2.5*3)/(45.5-3.5) );}}1.6public class Test{public static void main(String[]args){int i=1,sum=0;for(;i<=9;i++)sum+ =i;System.out.println(sum);}1.7public class Test{public static void main(String[]args){System.out.println(4*(1.0-1.0/3+1.0/5-1.0/7+1.0/9-1.0/11));System.out.println(4*(1.0-1.0/3+1.0/5-1.0/7+1.0/9-1.0/11+1.0/13));}}1.8public class Test{public static void main(String[]args){final double PI=3.14; double radius=5.5;System.out.println(2*radius*PI);System.out.println(PI*radius*radius);}}1.9public class Test{public static void main(String[]args){System.out.println(7.9*4.5);System.out.p rintln(2*(7.9+4.5));}}1.10public class Test{public static void main(String[]args){double S=14/1.6;double T=45*60+30;double speed=S/T;System.out.println(speed);}1.11public class Test{public static void main(String[]args){int BN=312032486; //original person numbers double EveryYS,EveryYBP,EveryYDP,EveryYMP;EveryY S=365*24*60*60;EveryYBP=EveryYS/7;EveryYDP=EveryYS/13;Every YMP=EveryYS/45;int FirstYP,SecondYP,ThirdYP,FourthYP,FivthYP;FirstYP=(int)(BN+EveryYBP+EveryYMP-EveryYDP);SecondYP=(int)(FirstYP +EveryYBP+EveryYMP-EveryYDP);ThirdYP=(int)(SecondYP+EveryYBP+Ev eryYMP-EveryYDP);FourthYP=(int)(ThirdYP+EveryYBP+EveryYMP-EveryYD P);FivthYP=(int)(FourthYP+EveryYBP+EveryYMP-EveryYDP);System.out.pri ntln(FirstYP);System.out.println(SecondYP);System.out.println(ThirdYP);Syste m.out.println(FourthYP);System.out.println(FivthYP);}}1.12public class Test{public static void main(String[]args){double S=24*1.6; double T=(1*60+40)*60+35;double speed=S/T;System.out.println(sp eed);}}1.13import java.util.Scanner;public class Test{public static void main(String[]args){Scanner input=new Scan ner(System.in);System.out.println("input a,b,c,d,e,f value please:");double a=input.nextDouble();double b=input.nextDouble();double c=input.nextDouble();double d=input. nextDouble();double e=input.nextDouble();第二章package cn.Testcx;import java.util.Scanner;public class lesson2{public static void main(String[]args){@SuppressWarnings("resource")Scanner in put=new Scanner(System.in);System.out.print("请输入一个摄氏温度:");double Celsius=input.nextDouble();double Fahrenheit=(9.0/5)*Celsius+3 2;System.out.println("摄氏温度:"+Celsius+"度"+"转换成华氏温度为:"+Fahrenheit+"度");System.out.print("请输入圆柱的半径和高:");double radius=input.nextDouble();int higth=input.nextInt();double are as=radius*radius*Math.PI;double volume=areas*higth;System.out.println("圆柱体的面积为:"+areas);System.out.println("圆柱体的体积为:"+volume);System.out.print("输入英尺数:");double feet=input.nextDouble();double meters=feet*0.305;System.out.print ln(feet+"英尺转换成米:"+meters);System.out.print("输入一个磅数:");double pounds=input.nextDouble();double kilograms=pounds*0.454;Syste m.out.println(pounds+"磅转换成千克为:"+kilograms);System.out.println("输入分钟数:");long minutes=input.nextInt();long years=minutes/(24*60*365);long days=(minutes%(24*60*365))/(24*60);System.out.println(minutes+"分钟"+"有"+years+"年和"+days+"天");long totalCurrentTimeMillis=System.currentTimeMillis();long totalSeconds=t otalCurrentTimeMillis/1000;long currentSeconds=totalSeconds%60;long totalM inutes=totalSeconds/60;long currentMinutes=(totalSeconds%(60*60))/60;long currenthours=(totalMinutes/60)%24;System.out.print("输入时区偏移量:");byte zoneOffset=input.nextByte();long currentHour=(currenthours+(zoneOf fset*1))%24;System.out.println("当期时区的时间为:"+currentHour+"时"+currentMinutes+"分"+currentSeconds+"秒");System.out.print("请输入v0,v1,t:");double v0=input.nextDouble();double v1=input.nextDouble();doublet=input.nextDouble();float a=(float)((v1-v0)/t);System.out.println("平均加速度a="+a);System.out.println("输入水的重量、初始温度、最终温度:");double water=input.nextDouble();double initialTemperature=input.nextDou ble();double finalTemperature=input.nextDouble();double Q=water*(finalTemp erature-initialTemperature)*4184;System.out.println("所需热量为:"+Q);System.out.print("输入年数:");int numbers=input.nextInt();long oneYearsSecond=365*24*60*60;Longpop ulation=(long)((312032486+((oneYearsSecond/7.0)+(oneYearsSecond/45.0)-(oneYearsSecond/13.0))*numbers));System.out.println("第"+numbers+"年后人口总数为:"+population);System.out.print("输入速度单位m/s和加速度a单位m/s2:");double v=input.nextDouble();double a1=input.nextDouble();double l engthOfAirplane=(Math.pow(v,2))/(2*a1);System.out.println("最短长度为:"+lengthOfAirplane);System.out.print("输入存入的钱:");double money=input.nextInt();double monthRate=5.0/1200;for(int i=1;i<7; i++){double total=money*(Math.pow(1+monthRate,i));System.out.println("第"+i+"个月的钱为:"+total);//告诉我书上的银行在哪里,我要去存钱,半年本金直接翻6倍、、、}System.out.print("用户请输入身高(英寸)、体重(磅):");double height=input.nextDouble();double weight=input.nextDouble(); double BMI=(weight*0.45359237)/(Math.pow((height*0.0254),2));System.out.println("BMI的值为"+BMI);System.out.print("输入x1和y1:");System.out.print("输入x2和y2:");double x1=input.nextDouble();double y1=input.nextDouble();double x2 =input.nextDouble();double y2=input.nextDouble();double point1=Math.pow((x2-x1),2);double point2=Math.pow((y2-y1),2);double distance=Math.pow((point1+point2),(1.0/2));//也可以Math.pow((point1+point2),0.5)System.out.println("两点间的距离为:"+distance);System.out.print("输入六边形的边长:");double side=input.nextDouble();double area=(3*(Math.pow(3,0.5))*(Math.p ow(side,2)))/2;System.out.println("六边形的面积为:"+area);}}。
JAVA各章习题及答案

三、编程题 1.编写一个 Java Application 类型的程序,输出“This is my first Java Application! ” 。 【 编 程 分 析 】 要 编 写 Java Application 类 型 的 程 序 , 需 要 在 JCreator 中 创 建 一 个 Java Application 类型的工程,这时 JCreator 会自动创建程序框架,该框架包含一个公共类,其中 包含一个 main()方法。删除 main()方法中自动生成的代码,编写自己的代码即可。由于该程 序要求输出一句话,因此在 main() 方法中直接调用 System.out.println() 或 System.out.print() 方法即可实现。 【参考程序】 public class X3_1 { public static void main(String args[]){ System.out.println("This is my first Java Application!"); } } 【运行结果】 This is my first Java Application! 2.编写一个 Java Applet 类型的程序,输出“这是我的第一个 Java Applet 类型的程序” 。 【编程分析】 要编写一个 Java Applet 类型的程序,首先利用 JCreator 创建一个 Java Applet 类型的工程, 该工程自动创建两个文件,一个源文件(.java 文件)和一个 HTML 文件(.html 文件) ,源文件中包含一个公共类,其中包含两个方法,即 init()方法和 paint()方法,由于该 程序只是要求输出一句话, 因此只要将 paint()方法中 g.drawString()方法的第一个参数修改为 要输出的内容即可。如果不是利用 JCreator 开发工具,而是利用 J2SDK,则用户需要自己编 写 HTML 文件。 【参考程序】 import java.awt.*; import java.applet.*; public class X3_2 extends Applet { public void paint(Graphics g) { g.drawString("这是我的第一个 Java Applet 类型的程序",50,50); } } 【运行结果】
java语言程序设计课后习题答案

java语言程序设计课后习题答案第一章:计算机、程序和JAVA概述1、2、1什么是硬件和软件?答:硬件指计算机中可见的物理部分;而软件提供不可见的指令,这些指令控制硬件并使硬件完成特定的任务。
1、2、2列举计算机的5个主要硬件组件。
答:中央处理器(CPU);内存(主存);存储设备(磁盘、光盘);输入设备(鼠标、键盘);输出设备(显示器、打印机);通信设备(调制解调器、网卡)。
1、2、3编写“CPU”代表什么含义?测量CPU速度的单位是什么?答:CPU(Central Proceing Unit)中央处理单元,包括控制单元和算术、逻辑单元;单位是HZ,现在通常以MHZ,GHZ数量级衡量。
1、2、4什么是比特?什么是字节?答:bit是计算机物理设备中存储的最小单位;8个bit为1个byte。
1、2、5内存是用来做什么的?RAM代表什么?为什么内存成为RAM?答:内存用来存储程序和数据;RAM(Random-Acce Memory)-可随机访问存储介质;因为内存可以按任意顺序存取字节所以被称为RAM(按功能划分)。
1、2、6用于测量内存大小的单位是什么?用于测量磁盘大小的单位是什么?答:GB,TB1、2、7内存和永久存储设备的主要不同是什么?答:内存是易失性存储介质(断电即失),存储容量小,传输速度快;永久存储设备为非易失性存储介质(断电可留),存储容量大,传输速度慢。
1、3、1CPU能理解什么语言。
机器语言。
1、3、2什么是汇编语言?什么是汇编器?汇编语言能用短的描述性单词来表示每一条机器语言指令,是一种低级语言。
汇编器可以将汇编语言转换成机器语言。
1、3、3什么是高级编程语言?什么是源程序?很像英语,易于学习和使用的编程语言称为高级编程语言。
使用高级编程语言编写的程序称为源程序。
1、3、4什么是解释器?什么是编译器?解释器会逐条读取源代码中的语言,并立刻翻译成机器代码或者虚拟机器代码,然后立刻运行。
Java语言程序设计第14章习题参考答案.docx

习题十四参考答案1.什么是Web,其工作原理如何?答:Web是一种浏览器/服务器技术。
Web服务器分布在世界各地,存储着各种各样的信息。
Web的浏览器用来请求任何服务器上的信息,并负责显示这些信息。
Web工作原理:(1)用户在浏览器中输入要访问网页的URL地址(如:),向服务器发送浏览请求。
(2)Web服务器接收到请求后,把响应结果返回到浏览器,浏览器解析HTML,把内内容呈现给用户。
(3)通信完成,关闭连接。
2.JSP的工作原理是什么?答:JSP的工作过程如下:(1)当一个JSP页面第一次被请求或在上次调用后被修改过,服务器首先会把JSP页面转换成Servleto(2)在转换的过程中,若JSP页面存在语法错误,转换会被终止,并向服务器和客户端输出错误信息。
如果转换成功,转换后的Servlet会被编译成相应的类文件。
服务器加载该类文件并允许其实例完成需要的工作,把响应返回客户端浏览器。
(3)如果被请求的JSP文件在上次调用后没有被修改过,服务器直接调用已经转换编译过的类文件实例完成工作,把响应返回客户端浏览器。
(4)Sen-let被处理完毕以后,其生命周期结束,被Java虚拟机的垃圾回收器回收。
3.JSP的构成元素有哪些?答:一个JSP页面由模板元素和JSP元素构成。
模板元素指的是JSP引擎不处理的部分, 比如HTML. JavaScript和CSS等。
JSP元素指的是由JSP引擎直接处理的部分,这一部分必须符合JSP 语法,否则会导致编译错误。
JSP元素包括注释、指令元素、脚本元素和动作元素。
4.什么是内置对象? JSP的内置对象有哪些,各有何功能?答:所谓JSP内置对象就是町以不加声明就在JSP页面脚本中使用的成员变量。
卜面介绍常见的内置对象。
常用的内置对象有:(I)request对象。
该对象封装了用户提交的信息,通过调用该对象相应的方法可以获取封装的信息,即使用该对象可以获取用户提交信息。
Java程序设计各章习题及其答案

Java程序设计各章习题及其答案第一章习题及思考题1、Java程序是由什么组成的?一个程序中必须有public类吗?Java源文件的命名规则是怎样的?答:一个Java源程序是由若干个类组成。
一个Java程序不一定需要有public类:如果源文件中有多个类时,则只能有一个类是public 类;如果源文件中只有一个类,则不将该类写成public也将默认它为主类。
源文件命名时要求源文件主名应与主类(即用public修饰的类)的类名相同,扩展名为.java。
如果没有定义public类,则可以任何一个类名为主文件名,当然这是不主张的,因为它将无法进行被继承使用。
另外,对Applet小应用程序来说,其主类必须为public,否则虽然在一些编译编译平台下可以通过(在BlueJ下无法通过)但运行时无法显示结果。
2、怎样区分应用程序和小应用程序?应用程序的主类和小应用程序的主类必须用public修饰吗?答:Java Application是完整的程序,需要独立的解释器来解释运行;而Java Applet则是嵌在HTML编写的Web页面中的非独立运行程序,由Web浏览器内部包含的Java解释器来解释运行。
在源程序代码中两者的主要区别是:任何一个Java Application 应用程序必须有且只有一个main方法,它是整个程序的入口方法;任何一个Applet小应用程序要求程序中有且必须有一个类是系统类Applet的子类,即该类头部分以extends Applet结尾。
应用程序的主类当源文件中只有一个类时不必用public修饰,但当有多于一个类时则主类必须用public修饰。
小应用程序的主类在任何时候都需要用public来修饰。
3、开发与运行Java程序需要经过哪些主要步骤和过程?答:主要有三个步骤(1)、用文字编辑器notepad(或在Jcreator,Gel, BuleJ,Eclipse, Jbuilder等)编写源文件;(2)、使用Java编译器(如Javac.exe)将.java源文件编译成字节码文件.class;(3)、运行Java程序:对应用程序应通过Java解释器(如java.exe)来运行,而对小应用程序应通过支持Java标准的浏览器(如Microsoft Explorer)来解释运行。
Java程序设计 张永强 张墨华 第14章习题答案

第 14 章 网络编程请分析对比 TCP 协议与 UDP 协议的特点,以及它们通讯流程的区别。
参考 14.1.2 2. 解释在基于 TCP 的网络编程时 ServerSocket 和 Socket 的作用。
ServerSocket 实现了服务器套结字,它的实例需要注册到主机系统,并提供面向客户 端的请求侦听服务。
而 Socket 实现客户端套接字,基于 TCP 网络编程时的网络客户端可以 利用一个 Socket 实例和服务器端的 Socket 实例进行通信。
3. 解释在基于 UDP 的网络编程时 DatagramSocket 和 DatagramPacket 的作用。
DatagramSocket 表示用来发送和接收数据报包的套接字,数据报套接字是包投递服务 的发送或接收点。
DatagramPacket 数据报包用来实现无连接包投递服务。
4. 如果要捕捉端口重复使用的异常,应该使用哪个异常类? BindException 用来将套接字绑定到本地地址和端口时发生错误的情况下,抛出此异 常。
5. 对于对象的传输,在编程的时候要注意哪些问题?传输基础对象和非基础对象时,程 序编写有什么不同? 一个对象能否传输取决于该对象是否能够被串行化。
对于 JDK 提供的如 Integer、 String、Date 等类型的对象,由于已经被串行化,因此可以被直接传输,而使用用户自定 义的类,如果需要进行串行化传输,则该类要实现 Serializable 接口,并且保证该类的每 个要传输的属性其类型必须也是可串行化。
同时,由于 Socket 的通信是建立在双方的同步基础之上的,因此在进行非基础对象的传输 时,需要保证通信两端构造流的顺序必须按照相反的顺序构造。
6. 程序 14-6 给出了客户端的对象传输程序,请给出服务器端的改造程序,并调试运行。
1.package chap14.session4; public class Account { private String id; // 用户唯一的 id private String name;// 用户名称 private int balance;// 当前余额 public Account(String id, String name, int balance) { super(); this.id = id; = name;this.balance = balance; } public Account(String id, String name) { super(); this.id = id; = name; this.balance = 0; } // 这里省略了每个属性的 getter 和 setter 方法,请创建时自行添加。
java语言程序设计基础篇第十版第十四章练习答案

}
}
// Create a scene and place it in the stage
Scene scene = new Scene(pane);
primaryStage.setTitle("Exercise14_02"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
* JavaFX support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}
}
02Байду номын сангаас
public class Exercise14_02 extends Application {
* JavaFX support. Not needed for running from the command line.
*/
public static void main(String[] args) {
launch(args);
}}
05
public class Exercise14_05 extends Application {
for (int i = 0; i < 5; i++) {
Text txt = new Text("Java");
txt.setRotate(90);
txt.setFont(font);
txt.setFill(new Color(Math.random(), Math.random(), Math.random(), Math.random()));
java语言程序设计基础篇第十版第十四章练习答案

java语言程序设计基础篇第十版第十四章练习答案01public class Exercise14_01 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {GridPane pane = new GridPane();pane.setAlignment(Pos.CENTER);pane.setHgap(5);pane.setVgap(5);ImageView imageView1 = new ImageView("image/uk.gif");ImageView imageView2 = new ImageView("image/ca.gif");ImageView imageView3 = new ImageView("image/china.gif");ImageView imageView4 = new ImageView("image/us.gif");pane.add(imageView1, 0, 0);pane.add(imageView2, 1, 0);pane.add(imageView3, 0, 1);pane.add(imageView4, 1, 1);// Create a scene and place it in the stageScene scene = new Scene(pane);primaryStage.setTitle("Exercise14_01"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}02public class Exercise14_02 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {Image imageX = new Image("image/x.gif");Image imageO = new Image("image/o.gif");GridPane pane = new GridPane();pane.setAlignment(Pos.CENTER);pane.setHgap(5);pane.setVgap(5);for (int i = 0; i < 3; i++) {for (int j = 0; j < 3; j++) {int status = (int)(Math.random() * 3);if (status == 0) {pane.add(new ImageView(imageX), j, i);}else if (status == 1) {pane.add(new ImageView(imageO), j, i);}}}// Create a scene and place it in the stageScene scene = new Scene(pane);primaryStage.setTitle("Exercise14_02"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}* The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}03public class Exercise14_03 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {// There are two ways for shuffling. One is to use the hint in the book. ArrayList list = new ArrayList<>();for (int i = 1; i <= 52; i++) {list.add(i);}HBox pane = new HBox(5);pane.setAlignment(Pos.CENTER);pane.getChildren().add(new ImageView("image/card/" + list.get(0) + ".png")); pane.getChildren().add(new ImageView("image/card/" + list.get(1) + ".png")); pane.getChildren().add(new ImageView("image/card/" + list.get(2) + ".png")); // Create a scene and place it in the stage Scene scene = new Scene(pane);primaryStage.setTitle("Exercise14_03"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}04public class Exercise14_04 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {HBox pane = new HBox();pane.setAlignment(Pos.CENTER);Font font = Font.font("Times New Roman", FontWeight.BOLD,FontPosture.ITALIC, 22);for (int i = 0; i < 5; i++) {Text txt = new Text("Java");txt.setRotate(90);txt.setFont(font);txt.setFill(new Color(Math.random(), Math.random(), Math.random(), Math.random()));pane.getChildren().add(txt);}// Create a scene and place it in the stageScene scene = new Scene(pane, 200, 100);primaryStage.setTitle("Exercise14_04"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}05public class Exercise14_05 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {Pane pane = new Pane();Font font = Font.font("Times New Roman", FontWeight.BOLD,FontPosture.REGULAR, 35);String s = "WELCOME TO JAVA ";double radius = 80;for (int i = 0; i < s.length(); i++) {double alpha = 2 * Math.PI * (s.length() - i) / s.length(); Text txt = new Text(radius * Math.cos(alpha) + 120,120 - radius * Math.sin(alpha), s.charAt(i) + "");txt.setFont(font);txt.setRotate(360 * i / s.length() + 90);pane.getChildren().add(txt);}// Create a scene and place it in the stageScene scene = new Scene(pane, 240, 240);primaryStage.setTitle("Exercise14_05"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}05public class Exercise14_05 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {Pane pane = new Pane();Font font = Font.font("Times New Roman", FontWeight.BOLD,FontPosture.REGULAR, 35);String s = "WELCOME TO JAVA ";double radius = 80;for (int i = 0; i < s.length(); i++) {double alpha = 2 * Math.PI * (s.length() - i) / s.length(); Text txt = new Text(radius * Math.cos(alpha) + 120,120 - radius * Math.sin(alpha), s.charAt(i) + "");txt.setFont(font);txt.setRotate(360 * i / s.length() + 90);pane.getChildren().add(txt);}// Create a scene and place it in the stageScene scene = new Scene(pane, 240, 240);primaryStage.setTitle("Exercise14_05"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}06public class Exercise14_06 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {double WIDTH = 200;double HEIGHT = 200;Pane pane = new Pane();for (int i = 0; i < 8; i++) {boolean isWhite = i % 2 == 0;for (int j = 0; j < 8; j++) {Rectangle rectangle = new Rectangle(i * WIDTH / 8,j * HEIGHT / 8, WIDTH / 8, HEIGHT / 8);rectangle.setStroke(Color.BLACK);if (isWhite) {rectangle.setFill(Color.WHITE);}else {rectangle.setFill(Color.BLACK);}isWhite = !isWhite;pane.getChildren().add(rectangle);}}// Create a scene and place it in the stageScene scene = new Scene(pane, WIDTH, HEIGHT);primaryStage.setTitle("Exercise14_06"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}07public class Exercise14_07 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {double WIDTH = 200;double HEIGHT = 200;GridPane pane = new GridPane();for (int i = 0; i < 10; i++) {for (int j = 0; j < 10; j++) {TextField tf = new TextField((int)(Math.random() + 0.5) + "");tf.setPrefColumnCount(1);tf.setAlignment(Pos.CENTER);pane.add(tf, j, i);}}// Create a scene and place it in the stageScene scene = new Scene(pane, WIDTH, HEIGHT);primaryStage.setTitle("Exercise14_07"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}08public class Exercise14_08 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {GridPane pane = new GridPane();for (int i = 0; i < 6; i++) {for (int j = 0; j < 9; j++) {pane.add(new ImageView("image/card/" + (i * 6 + j + 1) + ".png"), j, i); }}// Create a scene and place it in the stageScene scene = new Scene(pane, 600, 600);primaryStage.setTitle("Exercise14_08"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}09public class Exercise14_09 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {GridPane pane = new GridPane();pane.add(new FanPane(), 0, 0);pane.add(new FanPane(), 1, 0);pane.add(new FanPane(), 0, 1);pane.add(new FanPane(), 1, 1);// Create a scene and place it in the stageScene scene = new Scene(pane, 200, 200);primaryStage.setTitle("Exercise14_09"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}class FanPane extends Pane {double radius = 50;public FanPane() {Circle circle = new Circle(60, 60, radius);circle.setStroke(Color.BLACK);circle.setFill(Color.WHITE);getChildren().add(circle);Arc arc1 = new Arc(60, 60, 40, 40, 30, 35);arc1.setFill(Color.RED); // Set fill colorarc1.setType(ArcType.ROUND);Arc arc2 = new Arc(60, 60, 40, 40, 30 + 90, 35);arc2.setFill(Color.RED); // Set fill colorarc2.setType(ArcType.ROUND);Arc arc3 = new Arc(60, 60, 40, 40, 30 + 180, 35);arc3.setFill(Color.RED); // Set fill colorarc3.setType(ArcType.ROUND);Arc arc4 = new Arc(60, 60, 40, 40, 30 + 270, 35);arc4.setFill(Color.RED); // Set fill colorarc4.setType(ArcType.ROUND);getChildren().addAll(arc1, arc2, arc3, arc4);}}10public class Exercise14_10 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {Pane pane = new Pane();Ellipse ellipse = new Ellipse(100, 40, 50, 20);ellipse.setFill(Color.WHITE);ellipse.setStroke(Color.BLACK);Arc arc1 = new Arc(100, 140, 50, 20, 0, 180);arc1.setFill(Color.WHITE);arc1.setStroke(Color.BLACK);arc1.getStrokeDashArray().addAll(6.0, 21.0);Arc arc2 = new Arc(100, 140, 50, 20, 180, 180);arc2.setFill(Color.WHITE);arc2.setStroke(Color.BLACK);pane.getChildren().addAll(ellipse, arc1, arc2,new Line(50, 40, 50, 140), new Line(150, 40, 150, 140));// Create a scene and place it in the stageScene scene = new Scene(pane, 200, 200);primaryStage.setTitle("Exercise14_10"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited* JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}11public class Exercise14_11 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {Pane pane = new Pane();Circle circle = new Circle(100, 100, 80);circle.setFill(Color.WHITE);circle.setStroke(Color.BLACK);Circle circle1 = new Circle(70, 70, 10);Circle circle2 = new Circle(130, 70, 10);Ellipse ellipse1 = new Ellipse(70, 70, 20, 15);ellipse1.setFill(Color.WHITE);ellipse1.setStroke(Color.BLACK);Ellipse ellipse2 = new Ellipse(130, 70, 20, 15);ellipse2.setFill(Color.WHITE);ellipse2.setStroke(Color.BLACK);Line line1 = new Line(100, 80, 80, 120);Line line2 = new Line(80, 120, 120, 120);Line line3 = new Line(120, 120, 100, 80);Arc arc = new Arc(100, 130, 40, 15, 180, 180);arc.setFill(Color.WHITE);arc.setStroke(Color.BLACK);pane.getChildren().addAll(circle, ellipse1, ellipse2,circle1, circle2, line1, line2, line3, arc);// Create a scene and place it in the stageScene scene = new Scene(pane, 200, 200);primaryStage.setTitle("Exercise14_11"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}12public class Exercise14_12 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {Pane pane = new Pane();double height = 300;double paneHeight = 150;Rectangle r1 = new Rectangle(10, paneHeight - height * 0.2, 100, height * 0.2); r1.setFill(Color.RED);Text text1 = new Text(10, paneHeight - height * 0.2 - 10, "Project -- 20%"); Rectangle r2 = new Rectangle(10 + 110, paneHeight - height * 0.1, 100, height * 0.1);r2.setFill(Color.BLUE);Text text2 = new Text(10 + 110, paneHeight - height * 0.1 -10, "Quiz -- 10%");Rectangle r3 = new Rectangle(10 + 220, paneHeight - height * 0.3, 100, height * 0.3);r3.setFill(Color.GREEN);Text text3 = new Text(10 + 220, paneHeight - height * 0.3 - 10, "Midterm -- 30%");Rectangle r4 = new Rectangle(10 + 330, paneHeight - height * 0.4, 100, height * 0.4);r4.setFill(Color.ORANGE);Text text4 = new Text(10 + 330, paneHeight - height * 0.4 - 10, "Final -- 40%"); pane.getChildren().addAll(r1, text1, r2, text2, r3, text3, r4, text4);// Create a scene and place it in the stageScene scene = new Scene(pane, 500, paneHeight);primaryStage.setTitle("Exercise14_12"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}13public class Exercise14_13 extends Application {@Override // Override the start method in the Applicationclasspublic void start(Stage primaryStage) {Pane pane = new Pane();Arc arc1 = new Arc(100, 100, 80, 80, 0, 360 * 0.2);arc1.setFill(Color.RED);arc1.setType(ArcType.ROUND);Text text1 = new T ext(110, 80, "Project -- 20%");Arc arc2 = new Arc(100, 100, 80, 80, 360 * 0.2, 360 * 0.1);arc2.setFill(Color.BLUE);arc2.setType(ArcType.ROUND);Text text2 = new T ext(80, 15, "Quiz -- 10%");Arc arc3 = new Arc(100, 100, 80, 80, 360 * 0.2 + 360 * 0.1, 360 * 0.3);arc3.setFill(Color.GREEN);arc3.setType(ArcType.ROUND);Text text3 = new T ext(5, 100, "Midterm -- 30%");Arc arc4 = new Arc(100, 100, 80, 80, 360 * 0.2 + 360 * 0.1 + 360 * 0.3, 360 * 0.4);arc4.setFill(Color.ORANGE);arc4.setType(ArcType.ROUND);Text text4 = new T ext(100, 180, "Final -- 40%");pane.getChildren().addAll(arc1, text1, arc2, text2, arc3, text3, arc4, text4);// Create a scene and place it in the stageScene scene = new Scene(pane, 200, 200);primaryStage.setTitle("Exercise14_13"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}14public class Exercise14_14 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {Pane pane = new Pane();double paneWidth = 200;double paneHeight = 200;double width = paneWidth * 0.90 - 30;double height = paneWidth * 0.90 - 60;double diff = Math.min(width, height) * 0.4;// Draw the front rectangleRectangle r1 = new Rectangle(10, 60, width, height);r1.setFill(new Color(1, 1, 1, 0));r1.setStroke(Color.BLACK);// Draw the back rectangleRectangle r2 = new Rectangle(30, 60 - diff, width, height);r2.setFill(new Color(1, 1, 1, 0));r2.setStroke(Color.BLACK);// Connect the cornersLine line1 = new Line(10, 60, 30, 60 - diff);Line line2 = new Line(10, 60 + height, 30, 60 - diff + height);Line line3 = new Line(10 + width, 60, 30 + width, 60 - diff);Line line4 = new Line(10 + width, 60 + height, 30 + width, 60 - diff + height); pane.getChildren().addAll(r1, r2, line1, line2, line3, line4);// Create a scene and place it in the stageScene scene = new Scene(pane, paneWidth, paneHeight);primaryStage.setTitle("Exercise14_14"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}15public class Exercise14_15 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {// Create a pane, a polygon, and place polygon to paneStackPane pane = new StackPane();Polygon polygon = new Polygon();polygon.setFill(Color.RED);ObservableList list = polygon.getPoints();final double WIDTH = 200, HEIGHT = 200;double centerX = WIDTH / 2, centerY = HEIGHT / 2;double radius = Math.min(WIDTH, HEIGHT) * 0.4;// Add points to the polygon listfor (int i = 0; i < 8; i++) {list.add(centerX + radius * Math.cos(2 * i * Math.PI / 8 - Math.PI / 8)); list.add(centerY - radius * Math.sin(2 * i * Math.PI / 8 - Math.PI / 8)); }Text text = new Text("STOP");text.setFill(Color.WHITE);text.setFont(Font.font("Times New Roman", 40));pane.getChildren().addAll(polygon, text);// Create a scene and place it in the stageScene scene = new Scene(pane, WIDTH, HEIGHT);primaryStage.setTitle("Exercise14_15"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}16public class Exercise14_16 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {Pane pane = new Pane();Line line1 = new Line(0, 0, 0, 0);line1.startYProperty().bind(pane.heightProperty().divide(3));line1.endXProperty().bind(pane.widthProperty());line1.endYProperty().bind(pane.heightProperty().divide(3));line1.setStroke(Color.BLUE);Line line2 = new Line(0, 0, 0, 0);line2.startYProperty().bind(pane.heightProperty().multiply(2) .divide(3)); line2.endXProperty().bind(pane.widthProperty());line2.endYProperty().bind(pane.heightProperty().multiply(2). divide(3)); line2.setStroke(Color.BLUE);Line line3 = new Line(0, 0, 0, 0);line3.startXProperty().bind(pane.widthProperty().divide(3));line3.endXProperty().bind(pane.widthProperty().divide(3));line3.endYProperty().bind(pane.heightProperty());line3.setStroke(Color.RED);Line line4 = new Line(0, 0, 0, 0);line4.startXProperty().bind(pane.widthProperty().multiply(2). divide(3));line4.endXProperty().bind(pane.widthProperty().multiply(2).divid e(3));line4.endYProperty().bind(pane.heightProperty());line4.setStroke(Color.RED);pane.getChildren().addAll(line1, line2, line3, line4);// Create a scene and place it in the stageScene scene = new Scene(pane, 200, 200);primaryStage.setTitle("Exercise14_16"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}17public class Exercise14_17 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {Pane pane = new Pane();Arc arc = new Arc(60, 240, 40, 20, 0, 180); // Draw the base arc.setFill(Color.WHITE);arc.setStroke(Color.BLACK);Line line1 = new Line(20 + 40, 220, 20 + 40, 20); // Draw the poleLine line2 = new Line(20 + 40, 20, 20 + 40 + 100, 20); // Draw the hangerLine line3 = new Line(20 + 40 + 100, 20, 20 + 40 + 100, 40); // Draw the hanger // Draw the circleint radius = 20;Circle circle = new Circle(20 + 40 + 100, 40 + radius, radius); // Draw the hangercircle.setFill(Color.WHITE);circle.setStroke(Color.BLACK);// Draw the left armLine line4 = new Line(20 + 40 + 100 - radius * Math.cos(Math.toRadians(45)), 40 + radius + radius * Math.sin(Math.toRadians(45)),20 + 40 + 100 - 60, 40 + radius + 60);// Draw the right armLine line5 = new Line(20 + 40 + 100 + radius * Math.cos(Math.toRadians(45)), 40 + radius + radius * Math.sin(Math.toRadians(45)),20 + 40 + 100 + 60, 40 + radius + 60);// Draw the bodyLine line6 = new Line(20 + 40 + 100, 40 + 2 * radius,20 + 40 + 100, 40 + radius + 80);// Draw the left legLine line7 = new Line(20 + 40 + 100, 40 + radius + 80, 20 + 40 + 100 - 40, 40 + radius + 80 + 40);// Draw the right legLine line8 = new Line(20 + 40 + 100, 40 + radius + 80, 20 + 40 + 100 + 40, 40 + radius + 80 + 40);pane.getChildren().addAll(arc, line1, line2, line3, circle, line4, line5, line6, line7, line8);// Create a scene and place it in the stageScene scene = new Scene(pane, 400, 250);primaryStage.setTitle("Exercise14_17"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from thecommand line.*/public static void main(String[] args) {launch(args);}}18public class Exercise14_18 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {Pane pane = new Pane();Polyline polyline = new Polyline();ObservableList list = polyline.getPoints();double scaleFactor = 0.0125;for (int x = -100; x <= 100; x++) {list.add(x + 200.0);list.add(200 - scaleFactor * x * x);}Line line1 = new Line(10, 200, 390, 200);Line line2 = new Line(200, 30, 200, 390);// Draw arrowsLine line3 = new Line(390, 200, 370, 190);Line line4 = new Line(390, 200, 370, 210);Line line5 = new Line(200, 30, 190, 50);Line line6 = new Line(200, 30, 210, 50);// Draw x, y axis labelsText text1 = new T ext(380, 170, "X");Text text2 = new T ext(220, 40, "Y");pane.getChildren().addAll(polyline, line1, line2,line3, line4, line5, line6, text1, text2);// Create a scene and place it in the stageScene scene = new Scene(pane, 400, 250);primaryStage.setTitle("Exercise14_18"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}19public class Exercise14_19 extends Application {@Override // Override the start method in the Application class public void start(Stage primaryStage) {Pane pane = new Pane();Polyline polyline1 = new Polyline();ObservableList list1 = polyline1.getPoints();polyline1.setStroke(Color.RED);Polyline polyline2 = new Polyline();ObservableList list2 = polyline2.getPoints();polyline2.setStroke(Color.BLUE);double scaleFactor = 50;for (int x = -170; x <= 170; x++) {list1.add(x + 200.0);list1.add(100 - scaleFactor * Math.sin((x / 100.0) * 2 * Math.PI)); list2.add(x + 200.0);list2.add(100 - scaleFactor * Math.cos((x / 100.0) * 2 * Math.PI)); }Line line1 = new Line(10, 100, 390, 100);Line line2 = new Line(200, 10, 200, 200);// Draw arrowsLine line3 = new Line(390, 100, 370, 90);Line line4 = new Line(390, 100, 370, 110);Line line5 = new Line(200, 10, 190, 30);Line line6 = new Line(200, 10, 210, 30);// Draw x, y axis labelsText text1 = new T ext(380, 70, "X");Text text2 = new T ext(220, 20, "Y");// Draw -2piText text3 = new T ext(140, 115, "-\u03c0");Text text4 = new T ext(250, 115, "\u03c0");Text text5 = new T ext(90, 115, "-2\u03c0");Text text6 = new T ext(345, 115, "2\u03c0");Text text7 = new T ext(200, 115, "0");pane.getChildren().addAll(polyline1, polyline2, line1, line2, line3, line4, line5, line6, text1, text2, text3,text4, text5, text6, text7);// Create a scene and place it in the stageScene scene = new Scene(pane, 400, 250);primaryStage.setTitle("Exercise14_19"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}/*** The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from thecommand line.*/public static void main(String[] args) {launch(args);}}20public class Exercise14_20 extends Application {@Override // Override the start method in the Application classpublic void start(Stage primaryStage) {Pane pane = new Pane();double paneWidth = 300;double paneHeight = 250;double x1 = Math.random() * (paneWidth - 12);double y1 = Math.random() * (paneHeight - 12);double x2 = Math.random() * (paneWidth - 12);double y2 = Math.random() * (paneHeight - 12);drawArrowLine(x1, y1, x2, y2, pane);// Create a scene and place it in the stageScene scene = new Scene(pane, 400, 250);primaryStage.setTitle("Exercise14_20"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage}public static void drawArrowLine(double x1, double y1,double x2, double y2, Pane pane) {pane.getChildren().add(new Line(x1, y1, x2, y2));// find slope of this linedouble slope = ((((double) y1) - (double) y2))。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
01import class Exercise14_01 extends Application {@Override Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}02import class Exercise14_02 extends Application {@Override Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}03import class Exercise14_03 extends Application {@Override One is to use the hint in the book.ArrayList<Integer> list = new ArrayList<>();for (int i = 1; i <= 52; i++) {(i);}HBox pane = new HBox(5);;().add(new ImageView("image/card/" + (0) + ".png")); ().add(new ImageView("image/card/" + (1) + ".png")); ().add(new ImageView("image/card/" + (2) + ".png"));Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}04import class Exercise14_04 extends Application { @Override dd(txt);}Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}05import class Exercise14_05 extends Application { @Override dd(txt);}Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}05import class Exercise14_05 extends Application { @Override dd(txt);}Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}06import class Exercise14_06 extends Application { @Override dd(rectangle);}}Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}07import class Exercise14_07 extends Application {@Override Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}08import class Exercise14_08 extends Application {@Override ng"), j, i);}}Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}09import class Exercise14_09 extends Application { @Override Not needed for running from the command line. */public static void main(String[] args) {launch(args);}}class FanPane extends Pane {double radius = 50;public FanPane() {Circle circle = new Circle(60, 60, radius);;;getChildren().add(circle);Arc arc1 = new Arc(60, 60, 40, 40, 30, 35);; ddAll(arc1, arc2, arc3, arc4);}}10import class Exercise14_10 extends Application {@Override ddAll, ;Arc arc2 = new Arc(100, 140, 50, 20, 180, 180);;;().addAll(ellipse, arc1, arc2,new Line(50, 40, 50, 140), new Line(150, 40, 150, 140));Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}11import class Exercise14_11 extends Application {@Override ddAll(circle, ellipse1, ellipse2,circle1, circle2, line1, line2, line3, arc);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}12import class Exercise14_12 extends Application {@Override ddAll(r1, text1, r2, text2, r3, text3, r4, text4);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}13import class Exercise14_13 extends Application {@Override ddAll(arc1, text1, arc2, text2, arc3, text3, arc4, text4); Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}14import class Exercise14_14 extends Application { @Override ddAll(r1, r2, line1, line2, line3, line4);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}15import class Exercise14_15 extends Application { @Override ddAll(polygon, text);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}16import class Exercise14_16 extends Application {@Override ind().divide(3));().bind());().bind().divide(3));;Line line2 = new Line(0, 0, 0, 0);().bind().multiply(2).divide(3));().bind());().bind().multiply(2).divide(3));;Line line3 = new Line(0, 0, 0, 0);().bind().divide(3));().bind().divide(3));().bind());;Line line4 = new Line(0, 0, 0, 0);().bind().multiply(2).divide(3));().bind().multiply(2).divide(3));().bind());;().addAll(line1, line2, line3, line4);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}17import class Exercise14_17 extends Application {@Override ddAll(arc, line1, line2, line3, circle, line4, line5, line6, line7, line8);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}18import class Exercise14_18 extends Application {@Override ddAll(polyline, line1, line2,line3, line4, line5, line6, text1, text2);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}19import class Exercise14_19 extends Application {@Override ddAll(polyline1, polyline2, line1, line2,line3, line4, line5, line6, text1, text2, text3,text4, text5, text6, text7);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}20import class Exercise14_20 extends Application {@Override dd(new Line(x1, y1, x2, y2));dd(new Line(x2, y2, (x2 + (arctan + set45) * arrlen)),((y2)) + (arctan + set45) * arrlen)));().add(new Line(x2, y2, (x2 + (arctan - set45) * arrlen)),((y2)) + (arctan - set45) * arrlen)));}/*** The main method is only needed for the IDE with limited* JavaFX support. Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}21import class Exercise14_21 extends Application {@Override istance(x2, y2) + "");().addAll(circle1, circle2, line, text);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}import class Exercise14_22 extends Application { @Override ddAll(circle1, circle2, line, text1, text2);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}23import class Exercise14_23 extends Application { @Override ddAll(r1, r2, text);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}24import class Exercise14_24 extends Application { @Override ddAll(polygon, new Circle(x5, y5, 10), text);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}25import class Exercise14_25 extends Application { @Override ddAll(circle, polygon);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}26import class Exercise14_26 extends Application {@Override ddAll(clock1, clock2);Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}27import class Exercise14_27 extends Application { @OverrideNot needed for running from the command line.*/public static void main(String[] args) {launch(args);}}class DetailedClockPane extends Pane {private int hour;private int minute;private int second;lear();getChildren().addAll(circle, sLine, mLine, hLine);dd(new Line(xOuter, yOuter, xInner, yInner));}dd(text);}}}28import class Exercise14_28 extends Application { @OverrideNot needed for running from the command line.*/public static void main(String[] args) {launch(args);}}class ClockPaneWithBooleanProperties extends Pane {private int hour;private int minute;private int second;private boolean hourHandVisible = true;private boolean minuteHandVisible = true;private boolean secondHandVisible = true;public boolean isHourHandVisible() {return hourHandVisible;}public void setHourHandVisible(boolean hourHandVisible) {= hourHandVisible;paintClock();}public boolean isMinuteHandVisible() {return minuteHandVisible;}public void setMinuteHandVisible(boolean minuteHandVisible) { = minuteHandVisible;paintClock();}public boolean isSecondHandVisible() {return secondHandVisible;}public void setSecondHandVisible(boolean secondHandVisible) { = secondHandVisible;paintClock();}lear();getChildren().addAll(circle, t1, t2, t3, t4);if (secondHandVisible) {getChildren().add(sLine);}if (minuteHandVisible) {getChildren().add(mLine);}if (hourHandVisible) {getChildren().add(hLine);}}}29import class Exercise14_29 extends Application {final static double HGAP = 20;final static double VGAP = 20;final static double RADIUS = 5;final static double LENGTH_OF_SLOTS = 40;final static double LENGTH_OF_OPENNING = 15;final static double Y_FOR_FIRST_NAIL = 50;final static double NUMBER_OF_SLOTS = 9;final static double NUMBER_OF_ROWS = NUMBER_OF_SLOTS - 2;@Override dd(c);}}dd(new Line(x, y, x, y + LENGTH_OF_SLOTS));}dd(new Line(centerX - (NUMBER_OF_ROWS - 1) * HGAP / 2 - HGAP,y + LENGTH_OF_SLOTS, centerX - (NUMBER_OF_ROWS - 1) * HGAP / 2 + NUMBER_OF_ROWS * HGAP,y + LENGTH_OF_SLOTS));dd(new Line(centerX + HGAP / 2, Y_FOR_FIRST_NAIL + RADIUS,centerX - (NUMBER_OF_ROWS - 1) * HGAP / 2 + NUMBER_OF_ROWS * HGAP, y));().add(new Line(centerX - HGAP / 2, Y_FOR_FIRST_NAIL + RADIUS,centerX - (NUMBER_OF_ROWS - 1) * HGAP / 2 - HGAP, y));dd(new Line(centerX - HGAP / 2, Y_FOR_FIRST_NAIL + RADIUS,centerX - HGAP / 2, Y_FOR_FIRST_NAIL - LENGTH_OF_OPENNING));().add(new Line(centerX + HGAP / 2, Y_FOR_FIRST_NAIL + RADIUS, centerX + HGAP / 2, Y_FOR_FIRST_NAIL - LENGTH_OF_OPENNING));Not needed for running from the command line.*/public static void main(String[] args) {launch(args);}}。