📄 ticketauction.java
字号:
} else if (obj == confirm) { if (c == BACK_CMD) { display.setCurrent(bidForm); } else if (c == SUBMIT_CMD) { // display.setCurrent(submitMsg, notice); TimerService = new Timer(); TimerClient timerClient = new TimerClient(); TimerService.schedule(timerClient, 0, 1000); display.setCurrent(submitMsg); } } else if (obj == notice) { if (c == BACK_CMD) { display.setCurrent(confirm); } else if (c == BAND_CMD) { display.setCurrent(bandList); } } } } 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; class TicketItem { // Ticket info String name; // item name i.e. band name String seat; // seat number String sect; // seat section String date; // concert date String place; // concert place String state; // place's state // Bid info String id; // id i.e. item number String numItem; // quantity String begBid; // beginning bid price String curBid; // current bid price String incBid; // bid increment String numBids; // # of bids String endsAt; // Bid close time TicketItem(String name, String seat, String sect, String date, String place, String state, String id, String numItem, String begBid, String curBid, String incBid, String numBids, String endsAt) { this.name = name; this.seat = seat; this.sect = sect; this.date = date; this.place = place; this.state = state; this.id = id; this.numItem = numItem; this.begBid = begBid; this.curBid = curBid; this.incBid = incBid; this.numBids = numBids; this.endsAt = endsAt; } TicketItem(String name) { this(name, "n/a", "n/a", "n/a", "n/a", "n/a", "0", "0", "0", "0", "0", "0", "0"); } } class BandListTable { private Vector vec = new Vector(); BandListTable() { vec = new Vector(); } void put(int nth, Object obj) { Object o = null; try { o = vec.elementAt(nth); } catch (ArrayIndexOutOfBoundsException e) { o = null; } if (o == null) { vec.addElement(obj); } else { vec.setElementAt(obj, nth); } } Object get(String bandName) { int num = vec.size(); for (int i = 0; i < num; i++) { Object obj = vec.elementAt(i); if (obj instanceof Vector) { Vector v = (Vector) obj; TicketItem item = (TicketItem) v.elementAt(0); if (item.name.equals(bandName)) { return obj; } } } return null; } Object elementAt(int index) { return vec.elementAt(index); } void remove(int i) { Object o = null; try { o = vec.elementAt(i); } catch (ArrayIndexOutOfBoundsException e) { o = null; } if (o != null) { vec.removeElementAt(i); } } int size() { return vec.size(); } } Band() { table = new BandListTable(); TicketItem t; /** * 0: Mariah Carey */ t = new TicketItem("Mariah Carey", "18 & 19", "XF, Row 17", "Jun 28, 2001", "PacBell Stadium", "San Francisco, CA", "7720", "2", "45.00", "69.00", "2.00", "3", "11:00 am on Jun 25, 2001"); add(0, "Mariah Carey", t); /** * 1: Britney Spears */ t = new TicketItem("Britney Spears", "10", "F9, Row A", "Jun 30, 2001", "Civic Center", "Worchester, MA", "4509", "1", "20.00", "21.00", "1.00", "1", "9:45 pm on Jun 25, 2001"); add(1, "Britney Spears", t); t = new TicketItem("Britney Spears", "69 & 70", "PIT Row 1", "Jul 5, 2001", "Devore Ampitheatre", "Devore, CA", "3058", "2", "9.00", "175.00", "2.50", "40", "9:00 pm on Jun 27, 2001"); add(1, "Britney Spears", t); t = new TicketItem("Britney Spears", "5 & 6 & 7", "PIT Rw 11", "Aug 5, 2001", "Devore Ampitheatre", "Devore, CA", "3541", "3", "28.00", "97.00", "1.00", "11", "11:15 pm on Jul 30, 2001"); add(1, "Britney Spears", t); /** * 2: Ricky Martin */ t = new TicketItem("Ricky Martin", "11 & 12", "F Row J", "Jun 8, 2001", "Lakeview Ctr.", "Columbus, OH", "3861", "2", "60.00", "90.00", "5.00", "3", "6:30 pm on Jun 1, 2001"); add(2, "Ricky Martin", t); t = new TicketItem("Ricky Martin", "4 & 6", "N2 Row 5", "Sept 12, 2001", "Smitty Center", "Smith, NJ", "9916", "2", "70.00", "200.00", "10.00", "12", "9:30 pm on Sept 9, 2001"); add(2, "Ricky Martin", t); t = new TicketItem("Ricky Martin", "20 & 22", "KK Row 18", "Sept 14, 2001", "Gaylord Ctr", "Nashville, TN", "3869", "2", "75.00", "110.00", "2.00", "12", "4:00 pm on Sept 9, 2001"); add(2, "Ricky Martin", t); /** * 3: Tina Turner */ t = new TicketItem("Tina Turner", "7 & 8", "NN Row 7", "Jan 24, 2002", "Opera House", "Austin, TX", "1313", "2", "60.00", "67.00", "1.00", "7", "5:35 pm on Jan 15, 2002"); add(3, "Tina Turner", t); /** * 4: Bruce Springsteen */ t = new TicketItem("Bruce Springsteen", "N & O", "S, Row 14", "Aug 2, 2001", "3COM Park", "San Francisco, CA", "8120", "2", "80.00", "125.00", "2.00", "5", "11:30 am on Jul 26, 2001"); add(4, "Bruce Springsteen", t); /** * 5: Red Hot Chili Peppers */ t = new TicketItem("Red Hot Chili Peppers", "3 & 4", "M Row 12", "Oct 18, 2001", "Fillmore", "San Francisco, CA", "2255", "2", "90.00", "150.00", "1.00", "7", "7:30 pm on Oct 2, 2001"); add(5, "Red Hot Chili Peppers", 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.id + " " + item.name; } void getTicketData(Form form, String bandName, int nth) { TicketItem item = getTicketItem(bandName, nth); if (item == null) { return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -