Java++开实战经典第六章课后习题答案.docVIP

  • 11
  • 0
  • 约1.37万字
  • 约 9页
  • 2017-03-06 发布于贵州
  • 举报

Java++开实战经典第六章课后习题答案.doc

Java开实战经典第六章课后习题答案

interface ClassName public String getClassName ; class Company implements ClassName private String className ; public Company public Company String className this.className className ; public String getClassName return this.className ; public class ExecDemo01 public static void main String args[] ClassName cn new Company Company类 ; System.out.println cn.getClassName ; abstract class Shape public abstract float area ; class Triangle extends Shape private float foot ; private float height ; public Triangle public Triangle float foot,float height this.setFoot foot ; this.setHeight height ; public float area return this.foot * height / 2 ; public void setFoot float foot this.foot foot ; public void setHeight float height this.height height ; public float getFoot return this.foot ; public float getHeight return this.height ; class Cycle extends Shape private float radius ; private static final float PI 3.1415926f ; public Cycle public Cycle float radius this.setRadius radius ; public float area return PI * this.radius * this.radius ; public void setRadius float radius this.radius radius ; public float getRadius return this.radius ; public class ExecDemo02 public static void main String args[] Shape s1 new Triangle 30.0f,50.6f ; Shape s2 new Cycle 25.3f ; System.out.println s1.area ; System.out.println s2.area ; abstract class Person private String name ; private String addr ; private char sex ; private int age ; public Person public Person String name,String addr this name,addr,男,0 ; public Person String name,String addr,char sex,int age this.setName name ; this.setAddr addr ; this.setSex sex ; this.setAge age ; public abstract String getInfo ; public void setName String name this.name name ; public void setAddr String addr this.addr addr ; public void setSex char sex this.sex sex ; public void setAge int age this.age age ; public String getName return this.name ; public String getAd

文档评论(0)

1亿VIP精品文档

相关文档