隨堂筆記
/**
@author yuhuicun
@date 2021/4/20 14:48
*/
public class Phone {
public double width;
public double height;
public int weiht;
public String color;
/*
構(gòu)造方法? ? 1. 一定沒有返回值 2. 方法名字必須和類名完全一致
*/
// 無參構(gòu)造方法,不管寫不寫,系統(tǒng)都會(huì)生成
public Phone(){
? ? System.out.println("被調(diào)用北秽,有一個(gè)對(duì)象產(chǎn)生");
}
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("正在開機(jī)");
}
public void suopin(){
? ? System.out.println("手機(jī)即將鎖屏");
}
//方法的反復(fù)
public String toString(){
? ? return"{"+ this.weiht+""+this.height+""+this.weiht+""+this.color;
}