JAVA——查看手机配置与功能

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());
    }
}

在这里插入图片描述

import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.Image; import javax.microedition.lcdui.ImageItem; import javax.microedition.lcdui.Item; import javax.microedition.lcdui.TextField; public class PhoneAdd extends Form { private UIController controller; private Command BACK_COMMAND; private Command SAVE_COMMAND; private TextField nameField; private TextField phoneField; private TextField QQField; private TextField sexField; private TextField ageField; // private ImageItem iconQQ; // private Image icon; public PhoneAdd(String title, UIController control) { super(title); controller = control; this.setCommandListener(new PhoneAddListener()); BACK_COMMAND = new Command("返回", Command.BACK, 1); SAVE_COMMAND = new Command("确认", Command.OK, 2); this.addCommand(BACK_COMMAND); this.addCommand(SAVE_COMMAND); /* try{ icon=Image.createImage("/icon/7.png"); }catch(java.io.IOException e){ icon=null; System.out.println("图片导入异常"); } */ nameField = new TextField("名字", "", 16, TextField.ANY); phoneField = new TextField("电话", "", 16, TextField.PHONENUMBER); QQField = new TextField("QQ", "", 11, TextField.NUMERIC); sexField = new TextField("性别", "", 2, TextField.ANY); ageField = new TextField("年龄","",3,TextField.NUMERIC); // iconQQ=new ImageItem("",icon,Item.LAYOUT_LEFT,"图片无法显示"); this.append(nameField); this.append(phoneField); this.append(sexField); // this.append(iconQQ); this.append(QQField); this.append(ageField); } public void clear() { nameField.setString(""); phoneField.setString(""); sexField.setString(""); QQField.setString(""); ageField.setString(""); } private class PhoneAddListener implements CommandListener { public void commandAction(Command command, Displayable disp) { if (command == BACK_COMMAND) { controller.handleEvent(UIController.EventID.EVENT_VIEW_BACK, null); } else if (command == SAVE_COMMAND) { String name = nameField.getString(); String phone = phoneField.getString(); String QQ = QQField.getString(); String sex = sexField.getString(); String age= ageField.getString(); if ((name == null || name.equals("")) || (phone == null || phone.equals(""))) { return; } Object[] args = { name, phone, QQ, sex ,age}; controller.handleEvent(UIController.EventID.EVENT_NEW_SAVE, args); } } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大熊计算机毕设

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值