Initial commit
This commit is contained in:
28
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Table.java
Normal file
28
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Table.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.ex4;
|
||||
|
||||
public class Table extends Sobject{
|
||||
private double width; //宽度
|
||||
private double length; //长度
|
||||
private double height; //高度
|
||||
|
||||
//如果该类不写构造方法,系统会自动为 Table添加一个无参数的构造方法
|
||||
//在这个无参构造方法中,会自动调用Sobject类中的无参数的构造方法
|
||||
// public Table() {
|
||||
// super();
|
||||
//// super("abc",34.5);
|
||||
// }
|
||||
//
|
||||
public Table(String name,double weight,double width,double length,double height) {
|
||||
super(name, weight);
|
||||
this.width=width;
|
||||
this.length=length;
|
||||
this.height=height;
|
||||
|
||||
}
|
||||
public double area() {
|
||||
return width*length;
|
||||
}
|
||||
public void changeWeight(double w) {
|
||||
setWeight(w);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user