题目内容
阅读程序写结果classPoint{privatedoublex;privatedoubley;Point(doublex1,doubley1){x=x1;y=y1;}publicdoublegetX(){returnx;}publicdoublegetY(){returny;}publicvoidsetX(doublei){x=i;}publicvoidsetY(doublei){y=i;}}classCircle{privatePointo;privatedoubleradius;Circle(Pointp,doubler){o=p;radius=r;}Circle(doubler){o=newPoint(0.0,0.0);radius=r;}publicvoidsetO(doublex,doubley){o.setX(x);o.setY(y);}publicPointgetO(){returno;}publicdoublegetRadius(){returnradius;}publicvoidsetRadius(doubler){radius=r;}}publicclassTestCircle1{publicstaticvoidmain(Stringargs[]){Circlec1=newCircle(newPoint(1.0,2.0),2.0);Circlec2=newCircle(5.0);System.out.println("c1:("+c1.getO().getX()+","+c1.getO().getY()+"),"+c1.getRadius());System.out.println("c2:("+c2.getO().getX()+","+c2.getO().getY()+"),"+c2.getRadius());c1.setO(5,6);c2.setRadius(9.0);System.out.println("c1:("+c1.getO().getX()+","+c1.getO().getY()+"),"+c1.getRadius());System.out.println("c2:("+c2.getO().getX()+","+c2.getO().getY()+"),"+c2.getRadius());}}
查看答案
搜索结果不匹配?点我反馈