随堂笔记

随堂笔记



/**


@author yuhuicun

@date 2021/4/20 14:48

*/

public class Phone {

public double width;

public double height;

public int weiht;

public String color;

/*

构造方法    1. 一定没有返回值 2. 方法名字必须和类名完全一致

*/

// 无参构造方法,不管写不写,系统都会生成

public Phone(){

    System.out.println("被调用,有一个对象产生");

}

public Phone(double kuandu , double gaodu , int zhongliang , String yanse){

    width = kuandu;

    height = gaodu ;

    weiht = zhongliang;

    color = yanse;

}

public Phone (double kuandu , double gao , int zhongliang){

    width = kuandu;

    height = gao;

    weiht = zhongliang;

}


public Phone(int kuandu , int gao , int zhongliang){

    width = kuandu ;

    height = gao ;

    weiht = zhongliang ;

}


public void startUp(){

    System.out.println("正在开机");

}

public void suopin(){

    System.out.println("手机即将锁屏");

}



//方法的反复


public String toString(){

    return"{"+ this.weiht+""+this.height+""+this.weiht+""+this.color;

}

你可能感兴趣的:(随堂笔记)