Java2实用教程(第三版)实验指导与习题解答_第1页
Java2实用教程(第三版)实验指导与习题解答_第2页
Java2实用教程(第三版)实验指导与习题解答_第3页
Java2实用教程(第三版)实验指导与习题解答_第4页
Java2实用教程(第三版)实验指导与习题解答_第5页
已阅读5页,还剩82页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、1 java 2 实用教程(第三版)实实用教程(第三版)实 验指导与习验指导与习题解答题解答 清华大学出版清华大学出版社社 (编著(编著 耿祥义耿祥义 张跃平)张跃平) 实验模版代码实验模版代码及答案及答案 建议使用文档建议使用文档结构图结构图 (选择(选择 wordword菜单菜单视图视图文档结构图)文档结构图) 2 上机实践上机实践 1 初识初识 java.3 实验 1 一个简单的应用程序.3 实验 2 一个简单的 java applet程序 .3 实验 3 联合编译.4 上机实践上机实践 2 基本数据类型基本数据类型与控制语句与控制语句.5 实验 1 输出希腊字母表.5 实验 2 回文数

2、.6 实验 3 猜数字游戏.8 上机实践上机实践 3 类与对象类与对象.9 实验 1 三角形、梯形和圆形的类封装.9 实验 2 实例成员与类成员.12 实验 3 使用package语句与import语句.14 上机实践上机实践 4 继承与接口继承与接口.16 实验 1 继承.16 实验 2 上转型对象.19 实验接口回调.21 上机实践上机实践 5 字符串、时间与数字字符串、时间与数字.23 实验 1 string类的常用方法.23 实验 2 比较日期的大小.24 实验 3 处理大整数.25 上机实践上机实践 6 组件及事件处组件及事件处理理.26 实验 1 算术测试.26 实验 2 信号灯.

3、29 实验 3 布局与日历.31 上机实践上机实践 7 组件及事件处组件及事件处理理 2.35 实验 1 方程求根.35 实验 2 字体对话框.38 实验 3 英语单词拼写训练.41 上机实践上机实践 8 多线程多线程.45 实验 1 汉字打字练习.45 实验 2 旋转的行星.47 实验 3 双线程接力.51 上机实践上机实践 9 输入输出流输入输出流.54 实验 1 学读汉字.54 实验 2 统计英文单词字.57 实验 2 读取 zip文件.61 3 上机实践上机实践 10 java 中的网络编程中的网络编程.62 实验 1 读取服务器端文件.62 实验 2 使用套接字读取服务器端对象.64

4、 实验 3 基于 udp 的图像传输.67 上机实践上机实践 11 数据结构数据结构.71 实验 1 扫雷小游戏.71 实验 2 排序与查找.76 实验 3 使用 treeset排序.77 上机实践上机实践 12 java swing.79 实验 1 jlayeredpane分层窗格.79 实验 2 使用表格显示日历.80 实验 3 多文档界面(mdi).83 4 上机实践上机实践 1 初识初识 java 实验实验 1 一个简单的应一个简单的应用程序用程序 1答案:答案: 【代码 1】: system.out.println(你好,很高兴学习 java) ; 【代码 2】: system.ou

5、t.println(we are students) ; 2模板代码模板代码 hello.java public class hello public static void main (string args ) 【代码 1】 /命令行窗口输出你好,很高兴学习 java a a=new a(); a.fa(); class a void fa() 【代码 2】 /命令行窗口输出we are students 实验实验 2 一个简单的一个简单的 java applet程序程序 1答案:答案: 【代码 1】: g.drawstring(这是一个 java applet 程序,10,30); 【代

6、码 2】: g.drawstring(我改变了字体,20,50); 2模板代码模板代码 firstapplet.java 5 import java.applet.*; import java.awt.*; public class firstapplet extends applet public void paint(graphics g) g.setcolor(color.blue); 【代码 1】/在 java applet中绘制一行文字:“这是一个 java applet 程序” g.setcolor(color.red); g.setfont(new font(宋体,font.bo

7、ld,36); 【代码 2】/在 java applet中绘制一行文字:“我改变了字体” 实验实验 3 联合编译联合编译 1答案:答案: 【代码 1】: system.out.println(你好,只需编译我); 【代码 2】: system.out.println(i am a); 【代码 3】: system.out.println(i am b); 【代码 4】: system.out.println(i am c); 2模板代码模板代码 模板模板 1:hello.java public class mainclass public static void main (string ar

8、gs ) 【代码 1】 /命令行窗口输出你好,只需编译我 a a=new a(); a.fa(); b b=new b(); b.fb(); 模板模板 2 :a.java public class a void fa() 【代码 2】 /命令行窗口输出i am a 6 模板模板 3 :b.java public class b void fb() 【代码 3】 /命令行窗口输出i am b 模板模板 4 :c.java public class c void fc() 【代码 4】 /命令行窗口输出i am c 上机实践上机实践 2 基本数据类型基本数据类型与控制语句与控制语句 实验实验 1

9、输出希腊字母输出希腊字母表表 1答案:答案: 【代码 1】: startposition=(int)cstart; 【代码 2】: endposition=(int)cend ; 【代码 3】: c=(char)i; 2模板代码模板代码 greekalphabet.java public class greekalphabet public static void main (string args ) int startposition=0,endposition=0; char cstart=,cend=; 【代码 1】 /cstart做 int 型转换据运算,并将结果赋值给 startp

10、osition 【代码 2】 /cend 做 int 型转换运算,并将结果赋值给 endposition system.out.println(希腊字母在 unicode 表中的顺序位置:+(int)c); system.out.println(希腊字母表:); 7 for(int i=startposition;i=endposition;i+) char c=0; 【代码 3】 /i 做 char型转换运算,并将结果赋值给 c system.out.print( +c); if(i-startposition+1)%10=0) system.out.println(); 实验实验 2 回文

11、数回文数 1答案:答案: 【代码 1】: number=1 【代码 2】: d5=number/10000; 【代码 3】: d4=number%10000/1000; 【代码 4】: d3=number%1000/100; 【代码 5】: d5!=0 【代码 6】: d1=d5 public class number public static void main(string args) int number=0,d5,d4,d3,d2,d1; string str=joptionpane.showinputdialog(输入一个 1 至99999 之间的数); number=intege

12、r.parseint(str); if(【代码 1】) /判断 number 在 1 至 99999 之间的条件 【代码 2】 /计算 number 的最高位(万位)d5 【代码 3】 /计算 number 的千位 d4 【代码 4】 /计算 number 的百位 d3 d2=number%100/10; d1=number%10; if(【代码 5】) /判断 number 是 5 位数的条件 8 system.out.println(number+是 5 位数); if(【代码 6】) /判断 number 是回文数的条件 system.out.println(number+是回文数);

13、else system.out.println(number+不是回文数); else if(【代码 7】) /判断 number 是 4 位数的条件 system.out.println(number+是 4 位数); if(【代码 8】) /判断 number 是回文数的条件码 system.out.println(number+是回文数); else system.out.println(number+不是回文数); else if(【代码 9】) /判断 number 是 3 位数的条件 system.out.println(number+是 3 位数); if(【代码 10】) /判

14、断 number 是回文数的条件 system.out.println(number+是回文数); else system.out.println(number+不是回文数); else if(d2!=0) system.out.println(number+是 2 位数); if(d1=d2) system.out.println(number+是回文数); else 9 system.out.println(number+不是回文数); else if(d1!=0) system.out.println(number+是 1 位数); system.out.println(number+是

15、回文数); else system.out.printf(n%d 不在 1 至 99999 之间,number); 实验实验 3 猜数字游戏猜数字游戏 1答案:答案: 【代码 1】: yourguess!=realnumber 【代码 2】: yourguessrealnumber 【代码 3】: yourguessc 【代码 4】: boo=false; 【代码 5】: if(boo) length=sidea+sideb+sidec; return length; else system.out.println(不是一个三角形,不能计算周长); return 0; 【代码 6】: side

16、a=a;sideb=b;sidec=c; 【代码 7】: a+bc 【代码 9】: boo=false; 【代码 10】: above=a; bottom=b; height=h; 【代码 11】: area=(above+bottom)/2*height; 11 return area; 【代码 12】: radius=r; 【代码 13】: return 3.14*radius*radius; 【代码 14】: return 3.14*2*radius; 【代码 15】: circle=new circle(10); 【代码 16】: trangle=new trangle(3,4,5);

17、 【代码 17】: lader=new lader(3,4,10); 【代码 18】: length=circle.getlength(); 【代码 19】: area=circle.getarea(); 【代码 20】: length=trangle.getlength(); 【代码 21】: area=trangle.getarea(); 【代码 22】: area=lader.getarea(); 【代码 23】: trangle.setabc(12,34,1); 【代码 24】: area=trangle.getarea(); 【代码 25】: length=trangle.getle

18、ngth(); 2模板代码模板代码 areaandlength.java class trangle double sidea,sideb,sidec,area,length; boolean boo; public trangle(double a,double b,double c) 【代码 1】 /参数 a,b,c 分别赋值给sidea,sideb,sidec if(【代码 2】) /a,b,c 构成三角形的条件表达式 【代码 3】 /给 boo 赋值。 else 【代码 4】 /给 boo 赋值。 double getlength() 【代码 5】 /方法体,要求计算出 length

19、的值并返回 public double getarea() if(boo) double p=(sidea+sideb+sidec)/2.0; area=math.sqrt(p*(p-sidea)*(p-sideb)*(p-sidec) ; 12 return area; else system.out.println(不是一个三角形,不能计算面积); return 0; public void setabc(double a,double b,double c) 【代码 6】 /参数 a,b,c 分别赋值给sidea,sideb,sidec if(【代码 7】) /a,b,c 构成三角形的条

20、件表达式 【代码 8】 /给 boo 赋值。 else 【代码 9】 /给 boo 赋值。 class lader double above,bottom,height,area; lader(double a,double b,double h) 【代码 10】 /方法体,将参数 a,b,c 分别赋值给above,bottom,height double getarea() 【代码 11】 /方法体,,要求计算出 area 返回 class circle double radius,area; circle(double r) 【代码 12】 /方法体 double getarea() 【代

21、码 13】 /方法体,要求计算出 area 返回 13 double getlength() 【代码 14】 /getarea 方法体的代码,要求计算出 length 返回 void setradius(double newradius) radius=newradius; double getradius() return radius; public class areaandlength public static void main(string args) double length,area; circle circle=null; trangle trangle; lader l

22、ader; 【代码 15】 /创建对象 circle 【代码 16】 /创建对象 trangle。 【代码 17】 /创建对象 lader 【代码 18】 / circle调用方法返回周长并赋值给length system.out.println(圆的周长:+length); 【代码 19】 / circle调用方法返回面积并赋值给area system.out.println(圆的面积:+area); 【代码 20】 / trangle 调用方法返回周长并赋值给 length system.out.println(三角形的周长:+length); 【代码 21】 / trangle 调用方法

23、返回面积并赋值给 area system.out.println(三角形的面积:+area); 【代码 22】 / lader 调用方法返回面积并赋值给 area system.out.println(梯形的面积:+area); 【代码 23】 / trangle 调用方法设置三个边,要求将三个边修改为 12,34,1。 【代码 24】 / trangle 调用方法返回面积并赋值给 area system.out.println(三角形的面积:+area); 【代码 25】 / trangle 调用方法返回周长并赋值给 length system.out.println(三角形的周长:+len

24、gth); 14 实验实验 2 实例成员与类实例成员与类成员成员 1答案:答案: 【代码 1】: float a; 【代码 2】: static float b; 【代码 3】: this.a=a; 【代码 4】: this.b=b; 【代码 5】: a.b=100; 【代码 6】: a.inputb(); 【代码 7】: cat.seta(200); 【代码 8】: cat.setb(400); 【代码 9】: dog.seta(150); 【代码 10】:dog.setb(300); 【代码 11】:cat.inputa(); 【代码 12】:cat.inputb(); 【代码 13】:d

25、og.inputa(); 【代码 14】:dog.inputb(); 2模板代码模板代码 example.java class a 【代码 1】 /声明一个 float 型实例变量 a 【代码 2】 /声明一个 float 型类变量 b,即 static 变量 b void seta(float a) 【代码 3】 /将参数 a 的值赋值给成员变量 a void setb(float b) 【代码 4】 /将参数 b 的值赋值给成员变量 b float geta() return a; float getb() return b; void inputa() system.out.printl

26、n(a); 15 static void inputb() system.out.println(b); public class example public static void main(string args) 【代码 5】 /通过类名操作类变量 b,并赋值 100 【代码 6】 /通过类名调用方法 inputb() a cat=new a(); a dog=new a(); 【代码 7】 /cat 象调用方法 seta(int a)将 cat 的成员 a 的值设置为 200 【代码 8】 /cat 调用方法 setb(int b)将 cat 的成员 b 的值设置为 400 【代码

27、9】 /dog 象调用方法 seta(int a)将 dog 的成员 a 的值设置为 150 【代码 10】 /dog 调用方法 setb(int b)将 dog 的成员 b 的值设置为 300 【代码 11】 /cat 调用 inputa()。 【代码 12】 /cat 调用 inputb()。 【代码 13】 /dog 调用 inputa()。 【代码 14】 /dog 调用 inputb()。 实验实验 3 使用使用 package 语句与语句与import语句语句 1答案:无答案:无 2模板代码模板代码 squareequation.java package tom.jiafei; p

28、ublic class squareequation double a,b,c; double root1,root2; boolean boo; public squareequation(double a,double b,double c) this.a=a; this.b=b; this.c=c; if(a!=0) 16 boo=true; else boo=false; public void getroots() if(boo) system.out.println(是一元 2 次方程); double disk=b*b-4*a*c; if(disk=0) root1=(-b+ma

29、th.sqrt(disk)/(2*a); root2=(-b-math.sqrt(disk)/(2*a); system.out.printf(方程的根:%f,%fn,root1,root2); else system.out.printf(方程没有实根n); else system.out.println(不是一元 2 次方程); public void setcoefficient(double a,double b,double c) this.a=a; this.b=b; this.c=c; if(a!=0) boo=true; else boo=false; sunrise.java

30、 17 import tom.jiafei.*; class sunrise public static void main(string args ) squareequation equation=new squareequation(4,5,1); equation.getroots(); equation.setcoefficient(-3,4,5); equation.getroots(); 上机实践上机实践 4 继承与接口继承与接口 实验实验 1 继承继承 1答案:答案: 【代码 1】: public void speakhello() system.out.println(你好,

31、吃饭了吗?); 【代码 2】: public void averageheight() height=173; system.out.println(中国人的平均身高:+height+厘米); 【代码 3】: public void averageweight() weight=67.34; system.out.println(中国人的平均体重:+weight+公斤); 【代码 4】: system.out.println(坐如钟,站如松,睡如弓); 【代码 5】: public void speakhello() system.out.println(how do you do); 18

32、【代码 6】: public void averageheight() height=188; system.out.println(amerian average height:+height+ cm); 【代码 7】: public void averageweight() weight=80.23; system.out.println(amerian average weight:+weight+ kg); 【代码 8】: system.out.println(直拳、钩拳); 【代码 9】: public void speakhello() system.out.println(您好)

33、; 【代码 10】: public void averageheight() height=16; system.out.println(北京人的平均身高:+height+厘米); 【代码 11】: public void averageweight() weight=6; system.out.println(北京人的平均体重:+weight+公斤); 【代码 12】: system.out.println(京剧术语); 2模板代码模板代码 example.java class people protected double weight,height; public void speakh

34、ello() system.out.println(yayawawa); public void averageheight() height=173; 19 system.out.println(average height:+height); public void averageweight() weight=70; system.out.println(average weight:+weight); class chinapeople extends people 【代码 1】 /重写 public void speakhello()方法,要求输出类似“你好,吃了吗”这样的 /汉语信

35、息 【代码 2】 /重写 public void averageheight()方法,要求输出类似 /“中国人的平均身高:168.78 厘米”这样的汉语信息 【代码 3】 /重写 public void averageweight()方法, /要求输出类似“中国人的平均体重:65 公斤”这样的汉语信息 public void chinagongfu() 【代码 4】/输出中国武术的信息,例如:坐如钟,站如松,睡如弓等 class americanpeople extends people 【代码 5】 /重写 public void speakhello()方法,要求输出类似 /“how do

36、 you do”这样的英语信息。 【代码 6】 /重写 public void averageheight()方法 【代码 7】 /重写 public void averageweight()方法 public void americanboxing() 【代码 8】/输出拳击的信息,例如, “直拳” 、 “钩拳”等 class beijingpeople extends chinapeople 【代码 9】 /重写 public void speakhello()方法,要求输出类似“您好”这样的汉语信息 【代码 10】 /重写 public void averageheight()方法 【代

37、码 11】 /重写 public void averageweight()方法 public void beijingopera() 【代码 12】/输出京剧的信息 public class example 20 public static void main(string args) chinapeople chinapeople=new chinapeople(); americanpeople americanpeople=new americanpeople(); beijingpeople beijingpeople=new beijingpeople(); chinapeople.

38、speakhello(); americanpeople.speakhello(); beijingpeople.speakhello(); chinapeople.averageheight(); americanpeople.averageheight(); beijingpeople.averageheight(); chinapeople.averageweight(); americanpeople.averageweight(); beijingpeople.averageweight(); chinapeople.chinagongfu(); americanpeople.ame

39、ricanboxing(); beijingpeople.beijingopera() ; beijingpeople.chinagongfu(); 实验实验 2 上转型对象上转型对象 1答案:答案: 【代码 1】: public double earnings() return 50000.456; 【代码 2】: public double earnings() return 12*2300; 【代码 3】: public double earnings() return 52*500; 【代码 4】: for(int i=0;iemployee.length;i+) salaries=s

40、alaries+employeei.earnings(); 21 2模板代码模板代码 hardwork.java abstract class employee public abstract double earnings(); class yearworker extends employee 【代码 1】 /重写 earnings()方法 class monthworker extends employee 【代码 2】 /重写 earnings()方法。 class weekworker extends employee 【代码 3】 /重写 earnings()方法。 class c

41、ompany employee employee; double salaries=0; company(employee employee) this.employee=employee; public double salariespay() salaries=0; 【代码 4】 /计算 salaries。 return salaries; public class hardwork public static void main(string args) employee employee=new employee20; for(int i=0;iemployee.length;i+)

42、if(i%3=0) employeei=new weekworker(); 22 else if(i%3=1) employeei=new monthworker(); else if(i%3=2) employeei=new yearworker(); company company=new company(employee); system.out.println(公司年工资总额:+company.salariespay(); 实验实验接口回调接口回调 1答案:答案: 【代码 1】: public double computeweight() return 45.5; 【代码 2】: pu

43、blic double computeweight() return 65.5; 【代码 3】: public double computeweight() return 145; 【代码 4】: for(int k=0;kgoods.length;k+) totalweights=totalweights+puteweight(); 2模板代码模板代码 road.java interface computerweight public double computeweight(); class television implements computerweight 【代码 1】 /实现 c

44、omputeweight()方法。 class computer implements computerweight 23 【代码 2】 /实现 computeweight()方法。 class washmachine implements computerweight 【代码 3】 /实现 computeweight()方法。 class car computerweight goods; double totalweights=0; car(computerweight goods) this.goods=goods; public double gettotalweights() tot

45、alweights=0; 【代码 4】 /计算 totalweights return totalweights; public class road public static void main(string args) computerweight goodsone=new computerweight50, goodstwo=new computerweight22 ; for(int i=0;igoodsone.length;i+) if(i%3=0) goodsonei=new television(); else if(i%3=1) goodsonei=new computer(

46、); else if(i%3=2) goodsonei=new washmachine(); for(int i=0;i=0;i-) system.out.print( +ai); 实验实验 2 比较日期的大比较日期的大小小 模板代码模板代码 dateexample import java.util.*; import javax.swing.joptionpane; public class dateexample public static void main(string args ) string str=joptionpane.showinputdialog(输入第一个日期的年份:)

47、; int yearone=integer.parseint(str); str=joptionpane.showinputdialog(输入该年的月份:); int monthone=integer.parseint(str); str=joptionpane.showinputdialog(输入该月份的日期:); int dayone=integer.parseint(str); str=joptionpane.showinputdialog(输入第二个日期的年份:); int yeartwo=integer.parseint(str); str=joptionpane.showinput

48、dialog(输入该年的月份:); int monthtwo=integer.parseint(str); str=joptionpane.showinputdialog(输入该月份的日期:); int daytwo=integer.parseint(str); 26 calendar calendar=【代码 1】 /初始化日历对象 【代码 2】 /将 calendar 的时间设置为 yearone 年 monthone 月 dayone 日 long timeone=【代码 3】 /calendar 表示的时间转换成毫秒 【代码 4】 /将 calendar 的时间设置为 yeartwo

49、年 monthtwo 月 daytwo 日 long timetwo=【代码 5】 /calendar 表示的时间转换成毫秒。 date date1=【代码 6】 / 用 timeone 做参数构造 date1 date date2=【代码 7】 / 用 timetwo 做参数构造 date2 if(date2.equals(date1) system.out.println(两个日期的年、月、日完全相同); else if(date2.after(date1) system.out.println(您输入的第二个日期大于第一个日期); else if(date2.before(date1)

50、system.out.println(您输入的第二个日期小于第一个日期); long days=【代码 8】/计算两个日期相隔天数 system.out.println(yearone+年+monthone+月+dayone+日和 +yeartwo+年+monthtwo+月+daytwo+相隔+days+天); 实验实验 3 处理大整数处理大整数 模板代码模板代码 bigintegerexample import java.math.*; class bigintegerexample public static void main(string args) biginteger n1=new

51、 biginteger(987654321987654321987654321), n2=new biginteger(123456789123456789123456789), result=null; result=【代码 1】/n1 和 n2 做加法运算 system.out.println(和:+result.tostring(); result=【代码 2】/n1 和 n2 做减法运算 system.out.println(差:+result.tostring(); result=【代码 3】/n1 和 n2 做乘法运算 system.out.println(积:+result.to

52、string(); result=【代码 4】/n1 和 n2 做除法运算 27 system.out.println(商:+result.tostring(); biginteger m=new biginteger(1968957), count=new biginteger(0), one=new biginteger(1), two=new biginteger(2); system.out.println(m.tostring()+的因子有:); for(biginteger i=two;pareto(m)=0.5) operator=+; else operator=-; 28 r

53、eturn operator; public boolean getright(int answer) if(operator.equals(+) if(answer=numberone+numbertwo) right=true; else right=false; else if(operator.equals(-) if(answer=numberone-numbertwo) right=true; else right=false; return right; computerframe.java import java.awt.*; import java.awt.event.*;

54、public class computerframe extends frame implements actionlistener textfield textone,texttwo,textresult; button getproblem,giveanwser; label operatorlabel,message; teacher teacher; computerframe(string s) super(s); teacher=new teacher(); setlayout(new flowlayout(); textone=【代码 1】 /创建 textone,其可见字符长是

55、 10 texttwo=【代码 2】 /创建 texttwo,其可见字符长是 10 textresult=【代码 3】 /创建 textresult,其可见字符长是 10 operatorlabel=new label(+); message=new label(你还没有回答呢); getproblem=new button(获取题目); giveanwser=new button(确认答案); add(getproblem); add(textone); add(operatorlabel); add(texttwo); add(new label(=); add(textresult);

56、add(giveanwser); 29 add(message); textresult.requestfocus(); textone.seteditable(false); texttwo.seteditable(false); 【代码 4】/将当前窗口注册为 getproblem的 actionevent事件监视器 【代码 5】/将当前窗口注册为 giveanwser的 actionevent事件监视器 【代码 6】/将当前窗口注册为 textresult的 actionevent事件监视器 setbounds(100,100,450,100); setvisible(true); va

57、lidate(); addwindowlistener(new windowadapter() public void windowclosing(windowevent e) system.exit(0); ); public void actionperformed(actionevent e) if(【代码 7】) /判断事件源是否是 getproblem int number1=teacher.givenumberone(100); int number2=teacher.givenumbertwo(100); string operator=teacher.givetoperator

58、(); textone.settext(+number1); texttwo.settext(+number2); operatorlabel.settext(operator); message.settext(请回答); textresult.settext(null); if(【代码 8】) /判断事件源是否是 giveanwser string answer=textresult.gettext(); try int result=integer.parseint(answer); if(teacher.getright(result)=true) message.settext(你回

59、答正确); else message.settext(你回答错误); catch(numberformatexception ex) message.settext(请输入数字字符); textresult.requestfocus(); 30 validate(); mainclass.java public class mainclass public static void main(string args) computerframe frame; frame=【代码 9】/创建窗口,其标题为:算术测试 实验实验 2 信号灯信号灯 2模板代码模板代码 signalcanvas.java

60、 import java.awt.*; public class signalcanvas extends canvas int red,green,yellow,x,y,r; signalcanvas() setbackground(color.white); public void setred(int r) red=r; public void setgreen(int g) green=g; public void setyellow(int y) yellow=y; public void setposition(int x,int y) this.x=x; this.y=y; pu

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论