⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demoshipment.java

📁 it is a good tool to help you study java
💻 JAVA
字号:
class Box{
 private double width;     //这些成员被定义成私有
 private  double heigth;
 private  double depth;
Box(Box ob){
width=ob.width;
heigth=ob.heigth;
depth=ob.depth;
}
Box(double w,double h,double d){
width=w;
heigth=h;
depth=d;
}
Box(){
width=-1;
heigth=-1;
depth=-1;
}
Box(double len){
width=depth=heigth=len;
}
double vulume(){

return width*depth*depth;
}}
class BoxWeight extends Box{
double weight;
BoxWeight(BoxWeight ob){
super(ob);
weight=ob.weight;
}
BoxWeight(double w,double h,double d,double m){
super(w,h,d);
weight=m;
}
BoxWeight(){
super();
weight=-1;
}
BoxWeight(double len,double m){
super(len);
weight=m;
}
}
class Shipment extends BoxWeight{
public double cost;
Shipment(Shipment ob){
super(ob);//调用父类的构造函数以初始化继承自父类中的成员
cost=ob.cost;
}
Shipment(double w,double h,double d,double m,double c){
super(w,h,d,m);
cost=c;
}
Shipment(){
super();
cost=-1;
}
/*Shipmemt(double len,double m,double c){
super(len,m);
cost=c;
}*/
}
class DemoShipment{
public static void main(String args[]){
Shipment shipment1=new Shipment(10,20,15,10,3.41);
Shipment shipment2=new Shipment(2,3,4,0.76,1.28);
double vol;
vol=shipment1.vulume();
System.out.println("Volume of shipment1 is "+vol);
System.out.println("Weight of shipment1 is "+shipment1.weight);
System.out.println("Shipping cost is "+shipment1.cost);
System.out.println();
vol=shipment2.vulume();
System.out.println("Volume of shipment2 is "+vol);
System.out.println("Weight of shipment2 is "+shipment2.weight);
System.out.println("Shipping cost is "+shipment2.cost);


}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -