我是靠谱客的博主 可耐冬瓜,这篇文章主要介绍编写代码模拟手机与SIM卡的组合关系。,现在分享给大家,希望可以做个参考。

public class SIM {
long number;
SIM(long number){
this.number = number;
}
long getNumber() {
return number;
}
}
public class phone {
SIM sim;//声明对象
void setSIM(SIM card) {
sim = card;
}
long lookNumber() {
return sim.getNumber();
}
}
public class shouji {
public static void main(String[] args) {
SIM simOne = new SIM(18375431234L);//为对象分配实体
phone mobile = new phone();
mobile.setSIM(simOne);//调用方法setsim
System.out.println("手机号码:"+mobile.lookNumber());
SIM simTwo = new SIM(18375432345L);
mobile.setSIM(simTwo);
System.out.println("手机号码更换为:"+mobile.lookNumber());
}
}

最后

以上就是可耐冬瓜最近收集整理的关于编写代码模拟手机与SIM卡的组合关系。的全部内容,更多相关编写代码模拟手机与SIM卡内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(138)

评论列表共有 0 条评论

立即
投稿
返回
顶部