java程序运行结果题

阅读: 评论:0

java程序运行结果题

java程序运行结果题

ClassLevel{Stringname=””;intheight,width;publicLevel(){;}{name=le.name;height=le.height;width=le.width;}publicLevel(Stringna,inth,intw){name=na;height=h;width=w;}

Class Level

{String name=””;

int height,width;

public Level(){;}

{name=le.name;

height=le.height;

width=le.width; }

public Level(String na,int h,int w)

{name=na;

height=h;

width=w;}

public int higherthen(Level t)

{return this.height-t.height;}

public void print()

{System.out.println(“class Level:”);

System.out.println(“Name=;”+name+”,Height=;”+height+”,Width=;”+width);}

}

Class Leve2 extends Level

{int width;

public Leve2(){;}

public Leve2(Level le, int h,int w)

{super(le);

height=h;

width=w;}

public int widerthen()

{return width-super.width;}

public void print()

{System.out.println(“class Leve2:”);

System.out.println(“Name=;”+name+”,Height=;”+height+”,Width=;”+width);}

}

Public class Lev_ex

{ public static void main(String args[])

{Level le1=new Leve1(“Tower_1”,50,20);

Leve2 le2=new Leve2(le1,40,25);

Le1.print();

Le2.print();

System.out.println(“Level is”+le1.higherthen(le2)+”highter then Leve2.”);

System.out.println(“Level is”+le2.widerthen()+”wider then Level.”);

}

}

展开

本文发布于:2024-02-02 08:03:19,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170683220042459.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:程序   java
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23