package checkPhone;
class ToConfigure { // 配置类
private String PinPai ; // 品牌
private String XingHao; // 型号
private String XiTong; // 操作系统
private double JiaGe; // 价格
private int NeiChun; // 内存
public ToConfigure() {
}
public ToConfigure(String pinPai, String xingHao, String xiTong, double jiaGe, int neiChun) {
PinPai = pinPai;
XingHao = xingHao;
XiTong = xiTong;
JiaGe = jiaGe;
NeiChun = neiChun;
}
public String getPinPai() {
return PinPai;
}
public String getXingHao() {
return XingHao;
}
public String getXiTong() {
return XiTong;
}
public double getJiaGe() {
return JiaGe;
}
public int getNeiChun() {
return NeiChun;
}
}
class Function { // 功能类
private String BoHao; // 拨号
private String YouXi; // 游戏
private String BoFangGeQu; // 播放歌曲
public Function() {
}
public Function(String boHao, String youXi, String boFangGeQu) {
BoHao = boHao;
YouXi = youXi;
BoFangGeQu = boFangGeQu;
}
public String getBoHao() {
return BoHao;
}
public String getYouXi() {
return YouXi;
}
public String getBoFangGeQu() {
return BoFangGeQu;
}
}
public class SeeDemo { // 测试类
public static void main(String[] args) {
SeeDemo s = new SeeDemo();
ToConfigure to = new ToConfigure("华为","P900Pro","鸿蒙",5999,256);
Function ft = new Function("拨号","游戏","播放音乐");
ToConfigure to1 = new ToConfigure("小米","K50 pro","安卓",3999,256);
Function ft1 = new Function("拨号","游戏","播放音乐");
s.CanShu(to);
s.GongNeng(ft);
System.out.println("***************************");
s.CanShu(to1);
s.GongNeng(ft1);
}
public void CanShu(ToConfigure to){ // 定义参数方法
System.out.println("手机品牌:" + to.getPinPai() +"\n型号:" + to.getXingHao()
+"\n系统:" + to.getXiTong() +"\n内存:" + to.getNeiChun() + "G"
+"\n价格:" + to.getJiaGe() + "元");
}
public void GongNeng(Function ft){ // 定义功能方法
System.out.println("支持功能:" + ft.getBoHao() +","+ ft.getYouXi() +","+ ft.getBoFangGeQu());
}
}
JAVA——查看手机配置与功能
于 2022-03-27 12:20:37 首次发布