day06-面向对象-引用类型对象作为方法参数

This commit is contained in:
2026-01-19 09:54:43 +08:00
parent 28a022fb48
commit 54e8600789
2 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package com.inmind.object01;
/*
该类用来描述一个手机类
属性(成员变量)和行为(方法)
品牌
价格
颜色
尺寸
行为:
打电话
发短信
玩app
*/
public class Phone {
//品牌
String brand;
//价格
double price;
//颜色
String color;
//尺寸
double size;
//打电话
public void call(String number) {
System.out.println(""+number+"打电话");
}
//发短信
public void send(String number) {
System.out.println(""+number+"发短信");
}
//展示当前手机信息
public void show(){
System.out.println("一台品牌为"+brand+",颜色为"+color+",价格为"+price+",尺寸为"+size+"的手机");
}
}