?? mdeletecommand.java
字號:
package cmd;import core.*;import db.*;import java.util.List;import java.util.ArrayList;import javax.swing.JOptionPane;public class MDeleteCommand extends MDatabaseCommand{ private static final String [] PARAM_NAMES = { "id" }; private static final String [] PARAM_PROMPTS = { "Enter reservation id:" }; public MDeleteCommand () throws java.io.IOException { super (); } public String [] getParameterNames () { return PARAM_NAMES; } public String [] getParameterPrompts () { return PARAM_PROMPTS; } protected void executeDatabaseCommand (HotelDB database) { int id = Integer.parseInt (getParameter ("id")); // empty list value indicates that it worked String title = "Delete reservation: " + getParameter ("id"); if (database.deleteReservation (id)) displayResults (title, new ArrayList ()); // null value indicates no such reservation else displayResults (title, null); } protected void displayResultsText (String title, List flag) { if (flag == null) System.out.println ("No such reservation"); else System.out.println ("Reservation deleted."); } protected void displayResultsGUI (String title, List flag) { if (flag == null) JOptionPane.showMessageDialog(getFrame(), title, "Delete Command Error. No such reservation.", JOptionPane.ERROR_MESSAGE); else JOptionPane.showMessageDialog(getFrame(), title, "Deleted Command Succeeded", javax.swing.JOptionPane.INFORMATION_MESSAGE); } public String getMenuName () { return "Delete..."; } public String getName () { return "delete"; } public String getDescription () { return "Deletes a reservation by id"; } public Command makeInstance () { try { return new MDeleteCommand (); } catch (java.io.IOException e) { return null; } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -