パラメータとしてオブジェクトを使用します

パブリッククラス電話{ 
プライベート文字列の色。
プライベートint型の価格。
プライベート文字列ブランド。

公衆電話(){
}

公衆電話(文字色、INT価格、文字列ブランド){
this.color =色。
this.price =価格。
this.brand =ブランド。
}

パブリック文字列GETCOLOR(){
戻り色。
}

公共ボイドsetColorを(文字色){
this.color =色。
}

公共INT getPrice(){
戻り価格。
}

公共ボイドsetPrice(INT価格){
this.price =価格。
}

パブリック文字列thisはgetBrand(){
ブランドを返します。
}

公共ボイドsetBrand(文字列ブランド){
this.brand =ブランド;
}
}
========================================
パブリッククラスPHONE1 { 
パブリック静的無効メイン(文字列[] args){
電話1 =新しい携帯電話();
one.setBrand( "华为");
one.setColor( "金色");
one.setPrice(8888)。
携帯電話(1);
}
パブリック静的ボイド電話(電話のphone1){
System.out.printlnは(phone1.getBrand())。
System.out.println(phone1.getColor())。
System.out.println(phone1.getPrice())。
}
}

おすすめ

転載: www.cnblogs.com/xzwx668/p/12045916.html