搜索资源列表
hm6
- 抽象类的使用 设计一个类层次,定义一个抽象类--形状,其中包括有求形状的面积的抽象方法。 ----继承该抽象类定义三角型、矩形、圆。 ----编写一个主程序将一个三角形、矩形、圆存入一个数组中,将数组中各类图形的面积输出。-kind of abstract designs a class hierarchy, the definition of an abstract category -- shape, These include the shape of the area fo
jinjinlab
- 用java实现类的继承关系,用shape抽象类,对一些刚刚学习java的人会有一些帮助,了解java类的继承机制-using java to achieve the kind of inheritance, and shape the abstract category, just learning some of the java there will be some help to understand java class inheritance mechanism
Test3
- 定义4个类,MyShape、MyLine、MyRectangle和MyOval,其中MyShape是其他三个类的父类。MyShape为抽象类,包括图形位置的四个坐标;一个无参的构造方法,将所有的坐标设置为0;一个带参的构造函数,将所有的坐标设置为相应值;每个坐标的设置和读取方法;abstract void draw(Graphics g)方法。MyLine类负责画直线,实现父类的draw方法;MyRectangle负责画矩形,实现父类的draw方法;MyOval负责画椭圆,实现父类的draw方法
分别定义图形类Shape(抽象基类)
- 分别定义图形类Shape(抽象基类),继承类矩形类Rectangle、正方形类Square、 圆形类Circle;并且计算周长和面积。在另一个main函数中分别创建矩形、 正方形和圆形对象,设置所需的属性值,打印其周长和面积。(备注:只要把该文件解压,把里面的东东COPY去即可使用)-Graphics categories are defined Shape (abstract base class), the succession of quasi-rectangular type R
Shape
- 定义抽象类Shape,抽象方法为showArea(),求出面积并显示,定义矩形类Rectangle,正方形类Square,圆类 Circle,根据各自的属性,用showArea方法求出各自的面积,在main方法中构造3个对象,调用showArea方法-Define abstract class Shape, abstract methods showArea (), find the area and showed that define the rectangle class Rectangl
Count
- package Test3 interface Shape { public abstract double getArea() public static final double PI=3.14 //【代码一】:定义求形状面积的抽象方法 } class Triangle implements Shape { private double a private double b private double c pub
Abstrakte-Klasse-Anwendung
- 例子可以看到,类square、类circle及类triangle都是抽象类shape派生来的,他们都实现了getarea和getperimeter抽象方法。-Examples can be seen, like square, circle and classes are abstract classes triangle shape derived class to, they have achieved getarea and getperimeter abstract methods.
ShapeExp1
- 个人原创代码:矩形、圆形、正方形等形状的操作。编写Java Application程序,定义抽象类Shape,抽象方法为showArea(),求出面积并显示,定义矩形类Rectangle,正方形类Square,圆类 Circle,根据各自的属性,用showArea方法求出各自的面积,在main方法中构造3个对象,调用showArea方法。 定义接口DiagArea,其中包含方法double getDiagonal()求对角线长, double getArea()求面积,定义一个矩形类,实现此
ShapeExp2
- 个人原创代码:矩形、圆形、五角星等形状的操作。编写Java Application程序,创建一个接口Shape,其中有抽象方法area,类Circle 、Rectangle实现area方法计算其面积并返回。又有Star实现Shape的area方法,其返回值是0,Star类另有一返回值boolean型方法isStar;在main方法里创建一个Vector,根据随机数的不同向其中加入Shape的不同子类对象(如是1,生成Circle对象;如是2,生成Rectangle对象;如是3,生成Star对象)
JavaApplication7
- 定义一个抽象类Shape代表一个形状类,具有一个计算形状的面积的抽象方法,一个具有计算形状的周长的抽象方法。定义一个Shape类的子类Circle类表示一个圆,,此类具有一个表示半径的成员变量,实现这个类,定义一个单独的类测试此类。定义一个Shape类的子类Retangle类表示一个矩形,,此类具有表示高和宽的成员变量,实现这个类,定义一个单独的类测试此类-Define an abstract class Shape represents a shape class, with a calcul
shape
- 对抽象类shape的具体实现,重点强调对定义的理解和运用。-Concrete realization of the abstract class shape, with emphasis on understanding and application of the definition.
Abstract
- 如何使用抽象方法的示例。用抽象类实现对长方形,正方形,圆形面积的计算,然后实现对随机产生的是个图形面积的累加(图形的形状和长、宽、半径均随机产生)-Abstract class implements a pair of rectangular, square, circular area is calculated, and then implement the randomly generated graphics area accumulate (the shape of the graph
Shape
- 设Shape是圆、矩形、三角形共享的类,含有求圆的周长和面积的方法getCircumference()与getArea(),以及属性DEscr iptION以描述几何体的特征,试设计相关类圆、矩形、三角形类,并求圆、矩形、三角形的周长与面积。设计相应的测试类,求实际对象的面积与方法。(要求分别将Shape类用抽象、接口实现)-Let Shape is round, rectangular, triangular shared class containing the perimeter and
Mypicture
- 定义4个类,MyShape、MyLine、MyRectangle和MyOval,其中MyShape是其他三个类的父类。MyShape为抽象类,包括图形位置的四个坐标;一个无参的构造方法,将所有的坐标设置为0;一个带参的构造函数,将所有的坐标设置为相应值;每个坐标的设置和读取方法;abstract void draw(Graphics g)方法。MyLine类负责画直线,实现父类的draw方法;MyRectangle负责画矩形,实现父类的draw方法;MyOval负责画椭圆,实现父类的draw方法