java开发实战经典 李兴华 P217 6-2

package com.bjpowernode;

class Tuxing{
    private float longer;
    private float wide;
    private String name;
    public Tuxing(float longer,float wide,String name){
        this.longer = longer;
        this.wide = wide;
        this.name = name;
    }
    public String getName() {
        return name;
    }

    public float getLonger() {
        return longer;
    }

    public float getWide() {
        return wide;
    }
    public String getInfo(){
         return "名字 "+this.getName()+" 长度 "+this.getLonger()+" 宽度 "+this.getWide();
    }
}
public class MyTest{
    public static void main(String args[]){
        Tuxing t = new Tuxing(40.5f,20.0f,"火光");
        System.out.println(t.getInfo());
    }
}
名字 火光 长度 40.5 宽度 20.0

Process finished with exit code 0

你可能感兴趣的:(java开发实战经典 李兴华 P217 6-2)