⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newticketauction.java

📁 j2me Demos for example
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            pd.setLabel("Enter PIN:");            append(pd);            append(curBid);            append(incBid);            append(minBid);            append(bidText);            addCommand(BACK_CMD);            addCommand(NEXT_CMD);            setCommandListener(this);            ItemCommandListener icl = new MyItemCommandListener();            confirm.append("unknown");            confirm.addCommand(CANCEL_CMD);            confirm.setCommandListener(this);            auctionHyperlink.setDefaultCommand(AUCTION_CMD);            auctionHyperlink.setItemCommandListener(icl);            submitButton.setDefaultCommand(SUBMIT_CMD);            submitButton.setItemCommandListener(icl);            deleteFormItem(notice);            notice.append(new StringItem("Your bid has been received:", ""));            notice.append(new StringItem("Confirm #:", "12-B455-31"));            notice.addCommand(BAND_CMD);            notice.setCommandListener(this);            loginAlert.setTimeout(Alert.FOREVER);            auctionForm.append("unknown");            auctionForm.addCommand(BACK_CMD);            auctionForm.setCommandListener(this);        }        void setBid(String bandName, String bid) {            this.bandName = bandName;            this.bid = bid;        }        void setID(String bandName, String ticketID) {            this.bandName = bandName;            this.ticketID = ticketID;        }        void setBandAttributes(String bandName, int bandIndex) {            _bandName = bandName;            _bandIndex = bandIndex;        }        void doSubmit() {            TimerService = new Timer();            TimerClient timerClient = new TimerClient();            TimerService.schedule(timerClient, 0, 1000);            display.setCurrent(submitMsg);        }        public void commandAction(Command c, Displayable s) {            if (s instanceof Form) {                Form obj = (Form)s;                if (obj == this) {                    if (c == BACK_CMD) {                        display.setCurrent(band_ticket_Form);                    } else if (c == NEXT_CMD) {                        if ((id.getString().length() == 0) || (pd.getString().length() == 0)) { // ||                                                                                                // (bidText.getString().length() == 0)) {                            display.setCurrent(loginAlert);                        } else {                            login.setID(_bandName, band.getTicketID(_bandName, _bandIndex));                            String bidAmt = bidText.getString();                            System.err.println("\n\n #### bidAmt : " + bidAmt);                            // check if bid text is valid, if not pop up an alert                            if (bidAmt.equals("")) {                                Alert errorAlert =                                    new Alert("Alert",                                        "The bid amount you have entered is invalid.", null,                                        AlertType.ERROR);                                errorAlert.setTimeout(Alert.FOREVER);                                display.setCurrent(errorAlert);                            } else {                                deleteFormItem(login.confirm);                                login.confirm.append(new StringItem(                                        "Please confirm this information is correct before submitting your bid",                                        ""));                                auctionHyperlink.setText(login.ticketID);                                login.confirm.append(auctionHyperlink);                                login.confirm.append(new StringItem("Band: " + login.bandName, ""));                                login.confirm.append(new StringItem("Bid Amount:", "$" + bidAmt));                                login.confirm.append(submitButton);                                display.setCurrent(login.confirm);                            }                        }                    }                } else if (obj == confirm) {                    if (c == CANCEL_CMD) {                        display.setCurrent(this);                    }                } else if (obj == notice) {                    if (c == BAND_CMD) {                        display.setCurrent(band_ticket_Form);                    }                } else if (obj == auctionForm) {                    if (c == BACK_CMD) {                        display.setCurrent(confirm);                    }                }            }        }        class MyItemCommandListener implements ItemCommandListener {            public void commandAction(Command c, Item item) {                if (c == SUBMIT_CMD) {                    doSubmit();                } else if (c == AUCTION_CMD) {                    deleteFormItem(auctionForm);                    auctionForm.setTitle("Auction:" + login.ticketID);                    band.getAuctionData(auctionForm, login.bandName, login._bandIndex);                    display.setCurrent(auctionForm);                }            }        }        private class TimerClient extends TimerTask {            public final void run() {                if (submitGauge.getValue() == submitGauge.getMaxValue()) {                    TimerService.cancel();                    submitGauge.setValue(0);                    display.setCurrent(notice);                } else {                    submitGauge.setValue(submitGauge.getValue() + 10);                }            }        }    }    class Band {        private BandListTable table;        String def_ticker =            "BootWare & Fr. 2 tix $90.00 2 tix $110.00" + " 2 tix $200.00 Escalators in Images band... 2 tix $65.00";        String alt_ticker =            "Another Group LTD. 2 tix $58.00 4 tix $115.00" + " Jets 2 Jets 2 tix $37.00";        Band() {            table = new BandListTable();            TicketItem t;            /**             * 0: Ticket one             */            t = new TicketItem("BootWare & Friends", "18 & 19", "XF, Row 17", "Aug 23, 2002",                    "Eagle Stadium", "San Francisco, CA", "#7720", "2", "45.00", "69.00", "2.00",                    "3", "12:00 am on Aug 16, 2002");            add(0, "BootWare & Friends", t);            /**             * 1: Ticket two             */            t = new TicketItem("Escalators In Images band", "10, 11, 12, 13", "F9, Row A", "Sep 7, 2002",                    "Fly Center", "Santa Cruz, CA", "4509", "4", "100.00", "101.00", "1.00", "1",                    "9:45 pm on Sep 1, 2002");            add(1, "Escalators In Images band", t);            t = new TicketItem("Escalators In Images band", "69 & 70", "PIT Row 1", "Aug 9, 2002",                    "Montezuma Civic Amphitheatre", "Monterey, CA", "3058", "2", "9.00", "175.00",                    "2.50", "40", "9:00 pm on Aug 2, 2002");            add(1, "Escalators In Images band", t);            t = new TicketItem("Escalators In Images band", "5 & 6 & 7", "PIT Rw 11", "Aug 10, 2002",                    "Monterey Civic Amphitheatre", "Monterey, CA", "3541", "3", "28.00", "97.00",                    "1.00", "11", "11:15 pm on Aug 2, 2002");            add(1, "Escalators In Images band", t);            /**            * 2: Another group            */            t = new TicketItem("Another Group LTD.", "General Admission", "- NA -", "Aug 3, 2002",                    "Under the Hill", "San Francisco, CA", "3489", "2", "30.00", "44.00",                    "2.00", "5", "11:30 pm on Jul 7, 2002");            add(2, "Another Group LTD.", t);            /**             * 3:              */            t = new TicketItem("Jets 2 Jets", "General Admission", "- NA -", "Jul 19, 2001",                    "The Fillless", "San Francisco, CA", "3861", "2", "55.00", "62.50", "2.50",                    "3", "6:30 pm on Jul 12, 2002");            add(3, "Jets 2 Jets", t);            t = new TicketItem("Jets 2 Jets", "4 & 6", "N2 Row 5", "Jul 18, 2002",                    "Czech Gallery", "Mountain View, CA", "9916",                    "2", "65.00", "200.00", "10.00", "12", "9:30 pm on Jul 10, 2002");            add(3, "Jets 2 Jets", t);            /**             * 4: Kingware             */            t = new TicketItem("Kingware", "General Admission", "- NA -", "Aug 3, 2002",                    "Valley Stadium", "San Francisco", "1313", "2", "30.00", "37.00", "1.00",                    "7", "5:35 pm on Jul 27, 2002");            add(4, "Kingware", t);            /**             * 5: Anna And Her Nerves             */            t = new TicketItem("Anna And Her Nerves", "N & O", "S, Row 14", "Aug 3, 2002", "Bell Park",                    "San Francisco, CA", "8120", "2", "80.00", "125.00", "2.00", "5",                    "11:30 am on Jul 7, 2002");            add(5, "Anna And Her Nerves", t);            /**            * 6: The Human Experience & Co.            */            t = new TicketItem("The Human Experience & Co.", "15 & 16", "B, Row 14", "Aug 30, 2002",                    "Bell Park", "Prague, CZ", "1770", "2", "100.00", "175.00", "2.00", "5",                    "11:30 pm on Aug 23, 2002");            add(6, "The Human Experience & Co.", t);            /**             * 7: Thirty Thirsty Fourties             */            t = new TicketItem("Thirty Thirsty Fourties", "11 & 12", "F Row J", "Jul 19, 2001",                    "Open Amphitheatre", "Austin, TX", "3766", "2", "60.00", "90.00", "5.00",                    "3", "6:30 pm on Jul 12, 2002");            add(7, "Thirty Thirsty Fourties", t);            t = new TicketItem("Thirty Thirsty Fourties", "4 & 6", "N2 Row 5", "Jul 18, 2002",                    "Seattle Downtown", "Seattle, WA", "9135", "2", "70.00", "200.00", "10.00",                    "12", "9:30 pm on Jul 10, 2002");            add(7, "Thirty Thirsty Fourties", t);            t = new TicketItem("Thirty Thirsty Fourties", "General Admission", "- NA -",                    "Jul 20, 2002", "The Stadium", "San Francisco, CA", "2722", "2", "75.00",                    "110.00", "2.00", "12", "4:00 pm on Jul 13, 2002");            add(7, "Thirty Thirsty Fourties", t);        }        void add(String bandName) {            add(table.size(), bandName, new TicketItem(bandName));        }        void add(int i, String bandName) {            add(i, bandName, new TicketItem(bandName));        }        void add(int i, String bandName, TicketItem item) {            Object obj = table.get(bandName);            Vector vec = (obj == null) ? new Vector() : (Vector)obj;            vec.addElement(item);            table.put(i, vec);        }        void remove(int i) {            table.remove(i);        }        String[] getList() {            int num = table.size();            String[] seq = new String[num];            for (int i = 0; i < num; i++) {                Vector vec = (Vector)table.elementAt(i);                TicketItem item = (TicketItem)vec.elementAt(0);                seq[i] = item.name;            }            return seq;        }        String getName(int nth) {            Vector vec = (Vector)table.elementAt(nth);            if (vec != null) {                TicketItem item = (TicketItem)vec.elementAt(0);                if (item != null) {                    return item.name;                }            }            return null;        }        String[] getTicketList(String bandName) {            Object obj = table.get(bandName);            if (obj == null) {                return null;            }            Vector vec = (Vector)obj;            int num = vec.size();            String[] seq = new String[num];            for (int i = 0; i < num; i++) {                TicketItem item = (TicketItem)vec.elementAt(i);                seq[i] = new String("#" + item.id + " $" + item.curBid + "\n" + item.place + ", " +                        item.state + "\n" + item.sect + "," + item.seat + " ...");            }            return seq;        }        TicketItem getTicketItem(String bandName, int nth) {            Object obj = table.get(bandName);            if (obj == null) {                return null;            }            Vector vec = (Vector)obj;            return (TicketItem)vec.elementAt(nth);        }        String getTicketID(String bandName, int nth) {            TicketItem item = getTicketItem(bandName, nth);            if (item == null) {                return null;            }            return item.id;        }        String getTicketDataTitle(String bandName, int nth) {            TicketItem item = getTicketItem(bandName, nth);            if (item == null) {                return null;            }            return item.name + " " + item.id + ":";        }        void getTicketData(Form form, String bandName, int nth) {            TicketItem item = getTicketItem(bandName, nth);            if (item == null) {                return;            }            form.append(new StringItem("Quantity:", item.numItem + " tickets"));            form.append(new StringItem("Bid starts at:", "$" + item.begBid));            form.append(new StringItem("Current bid:", "$" + item.curBid));            form.append(new StringItem("Number of Bids:", item.numBids));            form.append(new StringItem("Bidding ends at:", item.endsAt));            // form.append(new StringItem("Sec:",     item.sect));            form.append(new StringItem("Seat(s):", item.seat));            form.append(new StringItem("Concert Date:", item.date));            form.append(new StringItem("Concert Venue:", item.place + "," + item.state));        }        void getAuctionData(Form form, String bandName, int nth) {            TicketItem item = getTicketItem(bandName, nth);            if (item == null) {                return;            }            form.append(new StringItem("Band Name:", item.name + " tickets"));            form.append(new StringItem("Concert Date:", item.date));            form.append(new StringItem("Quantity:", item.numItem));            form.append(new StringItem("Concert Venue:", item.place + "," + item.state));        }        String getCurrentBid(String bandName, int nth) {            TicketItem item = getTicketItem(bandName, nth);            if (item == null) {                return "";            }            return item.curBid;        }        boolean isTicketData(String bandName, String itemID) {            return (getTicketItem(bandName, itemID) == null) ? false : true;        }        TicketItem getTicketItem(String bandName, String itemID) {            Object obj = table.get(bandName);            if (obj == null) {                return null;            }            Vector vec = (Vector)obj;            int num = vec.size();            for (int i = 0; i < num; i++) {                TicketItem item = (TicketItem)vec.elementAt(i);                if (item.id.equals(itemID)) {                    return item;                }            }            return null;        }        void getTicketBidTitle(Form f, String bandName, int itemID) {            TicketItem item = getTicketItem(bandName, itemID);            long min = stringToLong1000(item.curBid) + stringToLong1000(item.incBid);            String minBid = long1000ToString(min);            login.curBid.setText("$" + item.curBid);            login.incBid.setText("$" + item.incBid);            login.minBid.setText("$" + minBid);        }        String toTickerString(boolean[] selected) {            String s = "";            if (selected == null) {                return alt_ticker;            }            // Rock Bands            if (selected[0]) {                s += def_ticker;            }            // Pop

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -