「java立方体最长路径」三角形最小路径和 Java

博主:adminadmin 2023-01-14 03:12:06 566

今天给各位分享java立方体最长路径的知识,其中也会对三角形最小路径和 Java进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

JAVA的作业,求大神啊~

public class Cube {

private float length;//长

private float width; //宽

private float height;//高

/**

* 构造方法

* 传递用户指定的长宽高

* @param length

* @param width

* @param height

*/

public Cube(float length, float width, float height) {

this.length = length;

this.width = width;

this.height = height;

}

/**

* 构造方法

* 始化立方体长宽高

*/

public Cube() {

this.length = 10f;

this.width = 10f;

this.height = 10f;

}

/**

* 修改长宽高的值

* @param length

* @param width

* @param height

*/

public void changeValue(float length, float width, float height){

this.length = length;

this.width = width;

this.height = height;

}

/**

* 计算体积

* @return

*/

public float volumeValue(){

return this.length*this.width*this.height;

}

public static void main(String[] args) {

//调用不同的方法进行测试

}

}

java的多级继承程序(题目:创建超类cuboid(长方体),其成员有height,width,length和计算机长方体的体积

package zhangyw.test;

/**

* 该类表示立方体,提供了计算体积的方法。

*

* @author Patina

* @since 2011.04.19

*

*/

public class Cuboid {

/** 立方体长 */

private long length;

/** 立方体宽 */

private long width;

/** 立方体高 */

private long height;

/**

* 使用长、宽、高构造Cuboid对象。

*

* @param length

* 立方体长

* @param width

* 立方体宽

* @param height

* 立方体高

*/

public Cuboid(long length, long width, long height) {

this.length = length;

this.width = width;

this.height = height;

}

/**

* 计算立方体的体积

*

* @return 立方体的体积

*/

public double volume() {

return this.length * this.width * this.height;

}

}

1:java 编写一个表示立方体的类Cube,它继承自类Square,还包含有表示立方体高的Drotected类型的成员变量h

class Square{

double w=0;

double l=0;

Square(double w,double l){

this.w=w;

this.l=l;

}

}

public class Cube extends Square{

protected double h=0;

Cube(double w,double l,double h){

super(w,l);

this.h=h;

}

public double volume(){

return super.w*super.l*this.h;

}

public static void main(String[] args) {

Cube Cube1=new Cube(3,2,1);

Cube Cube2=new Cube(7,3,2);

System.out.println(Cube1.volume());

System.out.println(Cube2.volume());

}

}

关于java立方体最长路径和三角形最小路径和 Java的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。