day06-面向对象特性之封装的实现_私有private

This commit is contained in:
2026-05-10 13:56:26 +08:00
parent 3689d77853
commit 153253c031
4 changed files with 73 additions and 4 deletions

View File

@@ -19,8 +19,8 @@ public class Demo03 {
System.out.println(p1.color);
System.out.println(p1.price);
System.out.println(p1.size);*/
//p1.show();
showPhone(p1);
p1.show();
// showPhone(p1);
//对象的行为操作
p1.call("10086");
@@ -37,8 +37,8 @@ public class Demo03 {
System.out.println(p2.color);
System.out.println(p2.price);
System.out.println(p2.size);*/
//p2.show();
showPhone(p2);
p2.show();
// showPhone(p2);
p2.call("10000");
p2.sendMsg("13666666666");

View File

@@ -34,6 +34,7 @@ public class Phone {
//展示自己的功能
public void show(){
String brand1 = "小米";//局部变量
System.out.println("品牌是"+brand+",颜色是"+color+",价格是"+price+"的手机");
}