Java程序设计之网络编程(第2版)各章习题和思考题答案(4)

2018-12-27 19:16

public void display(){

System.out.println(\

System.out.println(\

}

}

// class triangle

class triangle implements getProperty {

mpoint p1,p2,p3;

double s1,s2,s3;

String drawingName=\

triangle(mpoint p1,mpoint p2,mpoint p3){

this.p1=p1;

this.p2=p2;

this.p3=p3;

this.s1=Math.sqrt( (p1.x-p2.x)*(p1.x-p2.x)+ (p1.y-p2.y)*(p1.y-p2.y) );

this.s2=Math.sqrt( (p3.x-p2.x)*(p3.x-p2.x)+ (p3.y-p2.y)*(p3.y-p2.y) );

this.s3=Math.sqrt( (p1.x-p3.x)*(p1.x-p3.x)+ (p1.y-p3.y)*(p1.y-p3.y) );

}

public double getArea(){

double ss,ssa;

ss=(s1+s2+s3)*Pi/2.0/Pi;

ssa=Math.sqrt( ss*(ss-s1)*(ss-s2)*(ss-s3) );

return ssa;

}

public double getCircum(){

return s1+s2+s3;

}

public String getName(){

return drawingName;

}

public boolean tline(){

return true;

} } //

// circle class

class circle implements getProperty {

mpoint p1;

double radius;

String drawingName=\

circle(mpoint p1,double radius){

this.p1=p1;

this.radius=radius;

}

public double getArea(){

double ssa;

ssa=Math.PI*radius*radius;

return ssa;

}

public double getCircum(){

return Math.PI*2.0*radius;

}

public String getName(){

return drawingName;

}

public boolean tcircle(){

return true;

} }

// class rectangle

class rectangle implements getProperty {

mpoint p1,p2;

double s1,s2;

String drawingName=\

rectangle(mpoint p1,mpoint p2){

this.p1=p1;

this.p2=p2;

this.s1=Math.sqrt( (p1.x-p2.x)*(p1.x-p2.x) );

this.s2=Math.sqrt( (p1.y-p2.y)*(p1.y-p2.y) );

}

public double getArea(){

return s1*s2;

}

public double getCircum(){

return s1+s2+s1+s2;

}

public String getName(){

return drawingName;

}

public boolean rline(){

return true;

} }

// mainclass

class drawing extends disp {

drawing(double a, double b, String ss){

super(a,b,ss);

}

public static void main(String args[])throws IOException {

BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));

String strxx;

for(;true;) {

System.out.print(\、Rectangle or Circle:\

strxx=keyin.readLine();

if (strxx.length()==0) continue;

char charxx;

charxx=strxx.toUpperCase().charAt(0);

switch( charxx )

{

case 'T':

// triangle start

// 3point get


Java程序设计之网络编程(第2版)各章习题和思考题答案(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2017宁夏事业单位行测技巧:增长率

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: