ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:16.55KB ,
资源ID:11588883      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/11588883.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java web编程技术沈泽刚清华大学出版社第十四章课后习题部分解答.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java web编程技术沈泽刚清华大学出版社第十四章课后习题部分解答.docx

1、java web编程技术沈泽刚清华大学出版社第十四章课后习题部分解答Book14_1public class Book14_1 public static void main(String args) GeometricObject geoObject1 = new Circle(5); GeometricObject geoObject2 = new Rectangle(5, 3); System.out.println(The two objects have the same area? + equalArea(geoObject1, geoObject2); displayGeomet

2、ricObject(geoObject1); displayGeometricObject(geoObject2); public static boolean equalArea(GeometricObject object1, GeometricObject object2) return object1.getArea() = object2.getArea(); public static void displayGeometricObject(GeometricObject object) System.out.println(); System.out.println(The ar

3、ea is + object.getArea(); System.out.println(The perimeter is + object.getPerimeter(); abstract class GeometricObject private String color = white; private boolean filled; private java.util.Date dateCreated; protected GeometricObject() dateCreated = new java.util.Date(); protected GeometricObject(St

4、ring color, boolean filled) dateCreated = new java.util.Date(); this.color = color; this.filled = filled; public String getColor() return color; public void setColor(String color) this.color = color; public boolean isFilled() return filled; public void setFilled(boolean filled) this.filled = filled;

5、 public java.util.Date getDateCreated() return dateCreated; public String toString() return created on + dateCreated + ncolor: + color + and filled: + filled; public abstract double getArea(); public abstract double getPerimeter();class Circle extends GeometricObject private double radius; public Ci

6、rcle() public Circle(double radius) this.radius = radius; public Circle(double radius, String color, boolean filled) this.radius = radius; setColor(color); setFilled(filled); public double getRadius() return radius; public void setRadius(double radius) this.radius = radius; public double getArea() r

7、eturn radius * radius * Math.PI; public double getPerimeter() return 2 * radius * Math.PI; public void printCircle() System.out.println(The circle is created + getDateCreated() + and the radius is + radius); class Rectangle extends GeometricObject private double width; private double height; public

8、Rectangle() public Rectangle(double width, double height) this.width = width; this.height = height; public Rectangle(double width, double height, String color, boolean filled) this.width = width; this.height = height; setColor(color); setFilled(filled); public double getWidth() return width; public

9、void setWidth(double width) this.width = width; public double getHeight() return height; public void setHeight(double height) this.height = height; public double getArea() return width * height; public double getPerimeter() return 2 * (width + height); Book14_5import java.util.*;public class Book14_

10、5 public static void main(String args) Calendar calendar = new GregorianCalendar(); System.out.println(Current time is + new Date(); System.out.println(YEAR:t + calendar.get(Calendar.YEAR); System.out.println(MONTH:t + calendar.get(Calendar.MONTH); System.out.println(DATE:t + calendar.get(Calendar.D

11、ATE); System.out.println(HOUR:t + calendar.get(Calendar.HOUR); System.out.println(HOUR_OF_DAY:t + calendar.get(Calendar.HOUR_OF_DAY); System.out.println(MINUTE:t + calendar.get(Calendar.MINUTE); System.out.println(SECOND:t + calendar.get(Calendar.SECOND); System.out.println(DAY_OF_WEEK:t + calendar.

12、get(Calendar.DAY_OF_WEEK); System.out.println(DAY_OF_MONTH:t + calendar.get(Calendar.DAY_OF_MONTH); System.out.println(DAY_OF_YEAR:t + calendar.get(Calendar.DAY_OF_YEAR); System.out.println(AM_PM: + calendar.get(Calendar.AM_PM); Calendar calendar1 = new GregorianCalendar(2001, 8, 11); System.out.pri

13、ntln(September 11, 2001 is a + dayNameOfWeek(calendar1.get(Calendar.DAY_OF_WEEK); public static String dayNameOfWeek(int dayOfWeek) switch (dayOfWeek) case 1: return Sunday; case 2: return Monday; case 3: return Tuesday; case 4: return Wednesday; case 5: return Thursday; case 6: return Friday; case

14、7: return Saturday; default: return null; Book14_6public class Book14_6 public static void main(String args) Object objects = new Tiger(), new Chicken(), new Apple(); for (int i = 0; i (ComparableRectangle)o).getArea() return 1; else if (getArea() 0) return o1; else return o2; class Rectangle extend

15、s GeometricObject private double width; private double height; public Rectangle() public Rectangle(double width, double height) this.width = width; this.height = height; public Rectangle(double width, double height, String color, boolean filled) this.width = width; this.height = height; setColor(col

16、or); setFilled(filled); public double getWidth() return width; public void setWidth(double width) this.width = width; public double getHeight() return height; public void setHeight(double height) this.height = height; public double getArea() return width * height; public double getPerimeter() return

17、 2 * (width + height); abstract class GeometricObject private String color = white; private boolean filled; private java.util.Date dateCreated; protected GeometricObject() dateCreated = new java.util.Date(); protected GeometricObject(String color, boolean filled) dateCreated = new java.util.Date();

18、this.color = color; this.filled = filled; public String getColor() return color; public void setColor(String color) this.color = color; public boolean isFilled() return filled; public void setFilled(boolean filled) this.filled = filled; public java.util.Date getDateCreated() return dateCreated; publ

19、ic String toString() return created on + dateCreated + ncolor: + color + and filled: + filled; public abstract double getArea(); public abstract double getPerimeter();Book14_8import javax.swing.*;import java.awt.event.*;public class Book14_8 public static void main(String args) JFrame frame = new Ha

20、ndleEvent(); frame.setTitle(Handle Event); frame.setSize(200, 150); frame.setLocation(200, 100); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); class HandleEvent extends JFrame public HandleEvent() JButton jbtOk = new JButton(OK); JButton jbtCancel = new JButton(Cancel

21、); JPanel panel = new JPanel(); panel.add(jbtOk); panel.add(jbtCancel); add(panel); OKListenerClass listener1 = new OKListenerClass(); CancelListenerClass listener2 = new CancelListenerClass(); jbtOk.addActionListener(listener1); jbtCancel.addActionListener(listener2); class OKListenerClass implemen

22、ts ActionListener public void actionPerformed(ActionEvent e) System.out.println(Ok button clicked); class CancelListenerClass implements ActionListener public void actionPerformed(ActionEvent e) System.out.println(cancel button clicked); Book14_9import javax.swing.*;import java.awt.event.*;public cl

23、ass Book14_9 public static void main(String args) throws CloneNotSupportedException House house1 = new House(1, 1750.50); House house2 = (House)house1.clone(); System.out.println(house1 = house ? : + (house1 = house2); System.out.println(house1 equals to house2 ? : + house1.equals(house2); class Hou

24、se implements Cloneable, Comparable private int id; private double area; private java.util.Date whenBuilt; public House(int id, double area) this.id = id; this.area = area; whenBuilt = new java.util.Date(); public int getId() return id; public double getArea() return area; public java.util.Date getWhenBuilt() return whenBuilt; public Object clone() throws CloneNotSupportedException super.clone(); whenBuilt.clone(); return this; public int compareTo(Object o) if (area (House)o).area) return 1; else if (area (House)o).area) return -1; else return 0;

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1