欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

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

    • 资源ID:6797955       资源大小:16.55KB        全文页数:12页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    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;


    注意事项

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

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开