编写一个称作hypotenuse的Java程序,继承自下图表示的三角形类,并能从已知直角三角形的直角边计算最长边。
该类实现了一个接口 calc
Interface calc{
abstract float hypotenuseLong();
}
该类实现了一个接口 calc
Interface calc{
abstract float hypotenuseLong();
}
解决方案 »
- 正则表达式中匹配密码和验证首字母大写的问题
- Access数据库中sql语句问题!
- 各位帮着看一段怪异的代码(只有几行,但写法怪异).是servlet的源码里的.
- NIO中的Selector.select()的效率低?
- swing高手请进
- [110分]求javascript实现的类似java.net.URLEncoder.encode(String s) 的方法
- 如何查询树中的节点
- 为什么一个对一个错呢?
- 类级成员和对象级成员都是什么意思?
- JAVA?有何IDE好用?有Solaris平台上JDK为何不能做到至Turbo C 2.0那样的?
- 请教:Java中图形显示的问题。。。
- 急求!!!java 操作文件夹的问题,请大家帮忙!!
package com.test;public class Hypotenuse implements Calc { private float a; //直边1
private float b; //直边2
public Hypotenuse(float a,float b){
this.a =a;
this.b=b;
}
public float hypotenuseLong() {
return (new Float(Math.sqrt(a*a+b*b))).floatValue();
}
public float getA() {
return a;
}
public void setA(float a) {
this.a = a;
}
public float getB() {
return b;
}
public void setB(float b) {
this.b = b;
}
public static void main(String[] arg){
Hypotenuse hypotenuse=new Hypotenuse(3,4);
System.out.println(hypotenuse.hypotenuseLong());
}
}