文件名称:fourth-07301048
- 所属分类:
- JSP源码/Java
- 资源属性:
- [Java] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 36kb
- 下载次数:
- 0次
- 提 供 者:
- va***
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
第四次作业
1、 创建一个Animal(动物)类,让Horse(马),Dog(狗),Cat(猫)等动物继承Animal类。在Animal类中定义一些方法,让其子类重写这些方法,编写一个运行时多态的程序。
创建一个Animal类型的数组,在其中填充不同子类,然后调用自己的父类中的方法,看看会有什么情况发生。
2、 修改练习3.3,使Animal成为一个接口。
3、 在面向对象的绘图应用应用程序中,可以绘制圆形、矩形、直线等很多其他的图形对象。这些对象都具有相同的特定状态(例如位置、方向、线条颜色和填充颜色)和行为(例如移动、旋转、改变大小和绘制)。一些状态和行为对所有图形是相同的,例如位置、填充颜色和移动。另一些状态和行为需要不同的实现,例如改变大小和绘制。所有GraphicObject都知道如何绘制自己和如何改变自己的大小;只不过完成的操作不同。
请设计GraphicObject类和所有子类的方法,其中用到抽象类和抽象方法、抽象方法、方法的重写和多态、super关键字等概念。并测试其正确性。他们之间的关系用类图表示。
4 用策略模式实现网上书城不同类型的图书折扣策略,计算出每种类型的图书的价格。并编程测试之。
-err
1、 创建一个Animal(动物)类,让Horse(马),Dog(狗),Cat(猫)等动物继承Animal类。在Animal类中定义一些方法,让其子类重写这些方法,编写一个运行时多态的程序。
创建一个Animal类型的数组,在其中填充不同子类,然后调用自己的父类中的方法,看看会有什么情况发生。
2、 修改练习3.3,使Animal成为一个接口。
3、 在面向对象的绘图应用应用程序中,可以绘制圆形、矩形、直线等很多其他的图形对象。这些对象都具有相同的特定状态(例如位置、方向、线条颜色和填充颜色)和行为(例如移动、旋转、改变大小和绘制)。一些状态和行为对所有图形是相同的,例如位置、填充颜色和移动。另一些状态和行为需要不同的实现,例如改变大小和绘制。所有GraphicObject都知道如何绘制自己和如何改变自己的大小;只不过完成的操作不同。
请设计GraphicObject类和所有子类的方法,其中用到抽象类和抽象方法、抽象方法、方法的重写和多态、super关键字等概念。并测试其正确性。他们之间的关系用类图表示。
4 用策略模式实现网上书城不同类型的图书折扣策略,计算出每种类型的图书的价格。并编程测试之。
-err
(系统自动生成,下载前可以参看下载内容)
下载文件列表
实训第四次作业-07301048
.......................\Animal
.......................\......\.classpath
.......................\......\.project
.......................\......\bin
.......................\......\...\Animal.class
.......................\......\...\Cat.class
.......................\......\...\Dog.class
.......................\......\...\Horse.class
.......................\......\src
.......................\......\...\Animal.java
.......................\......\...\Cat.java
.......................\......\...\Dog.java
.......................\......\...\Horse.java
.......................\Count
.......................\.....\.classpath
.......................\.....\.project
.......................\.....\bin
.......................\.....\...\ABook.class
.......................\.....\...\BBook.class
.......................\.....\...\BookCount.class
.......................\.....\...\CBook.class
.......................\.....\...\TestStrategePattern.class
.......................\.....\src
.......................\.....\...\ABook.java
.......................\.....\...\BBook.java
.......................\.....\...\BookCount.java
.......................\.....\...\CBook.java
.......................\.....\...\TestStrategePattern.java
.......................\GraphicObject
.......................\.............\.classpath
.......................\.............\.project
.......................\.............\bin
.......................\.............\...\Circle.class
.......................\.............\...\GraphicObject.class
.......................\.............\...\Line.class
.......................\.............\...\Point.class
.......................\.............\...\TestGraphic.class
.......................\.............\src
.......................\.............\...\Circle.java
.......................\.............\...\GraphicObject.java
.......................\.............\...\Line.java
.......................\.............\...\Point.java
.......................\.............\...\TestGraphic.java
.......................\interfaceAnimal
.......................\...............\.classpath
.......................\...............\.project
.......................\...............\bin
.......................\...............\...\Animal.class
.......................\...............\...\Cat.class
.......................\...............\...\Dog.class
.......................\...............\...\Horse.class
.......................\...............\src
.......................\...............\...\Animal.java
.......................\...............\...\Cat.java
.......................\...............\...\Dog.java
.......................\...............\...\Horse.java
.......................\MediaDatabase
.......................\.............\.classpath
.......................\.............\.project
.......................\.............\bin
.......................\.............\...\AudioFile.class
.......................\.............\...\MediaDatabase.class
.......................\.............\...\MediaFile.class
.......................\.............\...\TestAudioFile.class
.......................\.............\...\TestMediaDatabase.class
.......................\.............\...\TestMediaFile.class
.......................\.............\src
.......................\.............\...\AudioFile.java
.......................\.............\...\MediaDatabase.java
.......................\.............\...\MediaFile.java
.......................\.............\...\TestAudioFile.java
.......................\.............\...\TestMediaDatabase.java
.......................\.............\...\TestMediaFile.java
.......................\Animal
.......................\......\.classpath
.......................\......\.project
.......................\......\bin
.......................\......\...\Animal.class
.......................\......\...\Cat.class
.......................\......\...\Dog.class
.......................\......\...\Horse.class
.......................\......\src
.......................\......\...\Animal.java
.......................\......\...\Cat.java
.......................\......\...\Dog.java
.......................\......\...\Horse.java
.......................\Count
.......................\.....\.classpath
.......................\.....\.project
.......................\.....\bin
.......................\.....\...\ABook.class
.......................\.....\...\BBook.class
.......................\.....\...\BookCount.class
.......................\.....\...\CBook.class
.......................\.....\...\TestStrategePattern.class
.......................\.....\src
.......................\.....\...\ABook.java
.......................\.....\...\BBook.java
.......................\.....\...\BookCount.java
.......................\.....\...\CBook.java
.......................\.....\...\TestStrategePattern.java
.......................\GraphicObject
.......................\.............\.classpath
.......................\.............\.project
.......................\.............\bin
.......................\.............\...\Circle.class
.......................\.............\...\GraphicObject.class
.......................\.............\...\Line.class
.......................\.............\...\Point.class
.......................\.............\...\TestGraphic.class
.......................\.............\src
.......................\.............\...\Circle.java
.......................\.............\...\GraphicObject.java
.......................\.............\...\Line.java
.......................\.............\...\Point.java
.......................\.............\...\TestGraphic.java
.......................\interfaceAnimal
.......................\...............\.classpath
.......................\...............\.project
.......................\...............\bin
.......................\...............\...\Animal.class
.......................\...............\...\Cat.class
.......................\...............\...\Dog.class
.......................\...............\...\Horse.class
.......................\...............\src
.......................\...............\...\Animal.java
.......................\...............\...\Cat.java
.......................\...............\...\Dog.java
.......................\...............\...\Horse.java
.......................\MediaDatabase
.......................\.............\.classpath
.......................\.............\.project
.......................\.............\bin
.......................\.............\...\AudioFile.class
.......................\.............\...\MediaDatabase.class
.......................\.............\...\MediaFile.class
.......................\.............\...\TestAudioFile.class
.......................\.............\...\TestMediaDatabase.class
.......................\.............\...\TestMediaFile.class
.......................\.............\src
.......................\.............\...\AudioFile.java
.......................\.............\...\MediaDatabase.java
.......................\.............\...\MediaFile.java
.......................\.............\...\TestAudioFile.java
.......................\.............\...\TestMediaDatabase.java
.......................\.............\...\TestMediaFile.java