JAVA面向对象明星类

public class _01Celebrity{
    //属性
    public String name;
    public int age;
    public double height;
    public char gender;
    
    //构造器
    public  _01Celebrity(String name,int age,double height,char gender){
        this.name = name;
        this.age = age;
        this.height = height;
        this.gender = gender;
    }
    
    //方法
    void sing(String sing) {
        System.out.println(this.name+" 唱: "+sing);
    }
    
    void dance(String dance) {
        System.out.println(this.name+" 跳: "+dance);    
    }
    
    void showUserInfo() {
        System.out.println("明星信息:姓名: "+this.name);    
        System.out.println("年龄: "+this.age);    
        System.out.println("身高: "+this.height);    
        System.out.println("性别: "+this.gender);    
    }
    
    public static void main(String[] args) {
        _01Celebrity zly = new _01Celebrity("赵丽颖",18,165,'女');
        _01Celebrity fengjie = new _01Celebrity("凤姐",28,168,'女');
        
        zly.showUserInfo();
        zly.sing("想你");
        zly.dance("流行舞蹈");
        System.out.println("=================================");    
        fengjie.showUserInfo();
        fengjie.sing("今天我要嫁给你");
        fengjie.dance("广场舞");
    }
}

 

posted @ 2018-04-25 08:43  马鞍山  阅读(253)  评论(0编辑  收藏  举报