77问答网
所有问题
当前搜索:
设计一个抽象类shape
java编写图形
抽象类
(
Shape
)
答:
class Circle extends
Shape
{ private static final double PI = 3.1415926;private double r;//定义
一个
构造函数 public Circle(double r){ this.r = r;} //重写
抽象
方法 public void girth() { double a =2*PI*r;super.setGirth(a);} public void area() { double b =PI*r*r;super...
定义
抽象基类Shape
,由它派生出5个派生类
答:
virtual void
shape
name() {cout<<"这是三角形"<<endl;} virtual int area() {return s*h/2;} };void main(){ int sum;circle c(3,5,2);square s(6,3);rectangle r(4,5);trapezoid t1(5,4,4);triangle t2(3,5);shape *p[5];p[0]=&c;p[
1
]=&s;p[2]=&r;p[3]=...
定义
一个抽象类
C
Shape
,包含纯虚函数Area(用来计算面积)和SetData(用 ...
答:
class CCircle:public C
Shape
{ float radius;public:void SetData();void Area(){cout<<"圆面积为:"<<3.14*radius<<endl;} };void CCircle::SetData(){ cout<<"请输入圆的半径:"<<endl;cin>>radius;} int main(){ CShape *
shape1
= new CTriange() ;shape1->SetData();shape1-...
请
设计一个抽象类
:平面图形类。planeGraphics 其中包括一个string类型...
答:
// 定义
抽象类
planeGraphics abstract class PlaneGraphics { private String
shape
;abstract Double area();// default构造函数 public PlaneGraphics() { this.shape = "未知";} // 带
一个
参数的构造函数 public PlaneGraphics(String shape) { this.shape = shape;} } ...
急:声明
一个抽象类Shape
,有抽象成员方法area和girth分别计算面积和周长...
答:
//Test.java public class Test { public static void main(String[] args) { Rectangle r = new Rectangle(12,10);System.out.println("面积:"+r.area());System.out.println("周长:"+r.girth());} } abstract class
Shape
{ public abstract int area();public abstract int girth();}...
java编程定义
一个shape抽象类
,具有求面积/求周长/显示输出功能._百度...
答:
楼主是不是想利用Java求
shape
文件中 面的面积,也就是polygon或者multipolygon的面积。实际上就是不规则多边形的面积,如果不用什么函数库(geotools)的话,还是有现成的公式的,非是通过定积分推倒了
一个
公式而已。需要注意的是:点要按照逆时针或者顺时针的顺序添加进list package geodemo;import java....
定义
抽象类Shape
,抽象方法为showArea(),求出面积并显示,定义矩形类Rec...
答:
private abstract class
Shape
{ public abstract void ShowArea();} private class Rectangle : Shape { public double Length { get; set; } public double Width { get; set; } public override void ShowArea(){ Console.WriteLine(this.Length * this.Width);} } private class Square : ...
写
一个
程序,定义
抽象基类shape
,派生5个派生类 虚函数
答:
using namespace std;const float PI = (float)3.14159;class
Shape
{ public:virtual float CalCircumference()=0;virtual float CalArea()=0;};//圆形 class Roundness: public Shape{ public:Roundness(float r):radius(r){} virtual float CalCircumference(){ return 2 * PI * radius;} vir...
定义
一个抽象类SHAPE
,在其中声明计算面积AREA()和周长PERINETER()方...
答:
我有个类似的,你看一下 import java.awt.*;import java.applet.*;abstract class
Shapes
{ protected int x,y,k;protected double m;public Shapes(int x,int y,int k,double m){this.x=x; this.y=y;this.k=k; this.m=m;} abstract public double getArea();abstract public ...
...
一个
完整的Java Application程序,包括
抽象类Shape
、MyTriangle类、Te...
答:
Shape
.java public abstract class Shape {public abstract double getArea();public abstract double getPerimeter();}MyTriangle.java public class MyTriangle extends Shape{//三遍double x,y,z;//周长的一半double p;//面积double S;public MyTriangle(double x, double y, double z){this.x=x...
<涓婁竴椤
1
2
3
4
5
6
7
8
9
10
涓嬩竴椤
灏鹃〉
其他人还搜