This document shows the whole program for the implementation of the Withdraw operation specication.

Size: px
Start display at page:

Download "This document shows the whole program for the implementation of the Withdraw operation specication."

Transcription

1 This document shows the whole program for the implementation of the Withdraw operation specication. * Account.java * 1 package ATM_BasicClasses; 3 import java.util.date; 4 5 public class Account { 6 public long id; 7 8 public int pass; 9 10 public int balance; 11 1 public int withdraw_limitation_per_day; public int withdraw_limitation_of_date_; public Date date_; public Account(long id, int pass, int balance, 19 int withdraw_limitation_per_day, int withdraw_limitation_of_date_, 0 Date date_) { 1 this.id = id; this.pass = pass; 3 this.balance = balance; 4 this.withdraw_limitation_per_day = withdraw_limitation_per_day; 5 this.withdraw_limitation_of_date_ = withdraw_limitation_of_date_; 6 this.date_ = date_; 7 } 8 } * Command.java * 1 package ATM_BasicClasses; 3 public abstract class Command implements java.io.serializable { 4 public int request_type = -1; 5 6 /* 7 * 0:withdraw 1: deposit : transfer 3: change password 4: show balance 5: 8 * print passbook -1: default 9 */ public long id = -1; 1 13 public int password = -1; 14 } * Command_Withdraw.java * 1

2 1 package ATM_BasicClasses; 3 public class Command_Withdraw extends Command { 4 public int withdraw_amount; 5 6 public Command_Withdraw(long id, int pass, int withdraw_amount) { 7 request_type = 0; 8 this.id = id; 9 this.password = pass; 10 this.withdraw_amount = withdraw_amount; 11 } 1 } * FoundAccount.java * 1 package ATM_BasicClasses; 3 public class FoundAccount { 4 public Account account; 5 6 public boolean found; 7 8 public FoundAccount() { 9 this.account = null; 10 found = false; 11 } 1 13 public FoundAccount(Account account) { 14 if (account!= null) { 15 this.account = account; 16 found = true; 17 } else { 18 this.account = null; 19 found = false; 0 } 1 } } * Response.java * 1 package ATM_BasicClasses; 3 public class Response implements java.io.serializable { 4 } * Response_Withdraw.java * 1 package ATM_BasicClasses; 3 public class Response_Withdraw extends Response { 4 public int success_or_fail; 5 6 /*-1: fail for undetermined reasons;

3 7 * 0: success; 8 * 1: fail because amount is over the balance 9 * : fail because id/password does not match 10 * 3: fail because amount is over the limitation in one day 11 */ 1 public Response_Withdraw(int result) { 13 success_or_fail = result; 14 } } * Accounts.java * 1 package ATM_Database; 3 import java.sql.*; 4 import java.text.simpledateformat; 5 import java.util.date; 6 7 import ATM_BasicClasses.FoundAccount; 8 import ATM_BasicClasses.Account; 9 10 public class Accounts { 11 1 private Connection con; private Statement stmt; public Accounts() { 17 try { 18 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 19 con = DriverManager.getConnection("jdbc:odbc:bank_accounts"); 0 stmt = con.createstatement(resultset.type_scroll_sensitive, 1 ResultSet.CONCUR_READ_ONLY); 3 } catch (Exception e) { 4 e.printstacktrace(); 5 } 6 } 7 8 public void ReleaseConnection() { 9 try { 30 stmt.close(); 31 con.close(); 3 } catch (Exception e) { 33 e.printstacktrace(); 34 } 35 } public FoundAccount Search_Account(long id, int Password) { 38 FoundAccount result = new FoundAccount(); try { 3

4 41 String sql = "SELECT * FROM Account where id=" + id + " And pass=" 4 + Password; 43 ResultSet rs; 44 rs = stmt.executequery(sql); if (rs.next()) { 47 Account account = new Account(rs.getLong("id"), rs 48.getInt("pass"), rs.getint("balance"), rs 49.getInt("withdraw_limitation_per_day"), rs 50.getInt("withdraw_limitation_of_date_"), rs 51.getDate("date_")); 5 result = new FoundAccount(account); 53 } 54 } catch (Exception e) { 55 } return result; 58 } public int Count_Accounts(long id, int Password) { 61 // return the number of accounts with the given id and password 6 int result = 0; try { 65 String sql = "SELECT * FROM Account where id=" + id + " And pass=" 66 + Password; 67 ResultSet rs; 68 rs = stmt.executequery(sql); while (rs.next()) { 71 result++; 7 } 73 } catch (Exception e) { 74 } if (result > 1) { 77 System.out.println("Tell database operator this exception!"); 78 } return result; 81 } 8 83 public int Count_Accounts(long id) { 84 // return the number of accounts with the given id 85 int result = 0; try { 88 String sql = "SELECT * FROM Account where id=" + id; 89 ResultSet rs; 90 rs = stmt.executequery(sql); 91 9 while (rs.next()) { 93 result++; 4

5 94 } 95 } catch (Exception e) { 96 } if (result > 1) { 99 System.out.println("Tell database operator this exception!"); 100 } return result; 103 } private boolean contains(account account) { 106 boolean result = false; 107 try { 108 String sql = "SELECT * FROM Account WHERE" + " id = " + account.id " AND pass = " + account.pass + " AND balance = " account.balance + " AND withdraw_limitation_per_day = " account.withdraw_limitation_per_day 11 + " AND withdraw_limitation_of_date_ = " account.withdraw_limitation_of_date_ + " AND date_ = #" new SimpleDateFormat("MM/dd/yyyy").format(account.date_) "#"; ResultSet rs = stmt.executequery(sql); if (rs.next()) { 10 result = true; 11 } 1 } catch (Exception e) { 13 e.printstacktrace(); 14 } 15 return result; 16 } public void Update_Account_Withdraw(Account account, int amount) { 19 try { 130 if (this.contains(account)) { 131 account.balance = account.balance - amount; 13 account.withdraw_limitation_of_date_ = account.withdraw_limitation_of_date_ amount; PreparedStatement Update; Update = con.preparestatement("update Account" + " SET" " balance = " + account.balance ", withdraw_limitation_of_date_ = " account.withdraw_limitation_of_date_ + " WHERE id = " account.id + " "); 14 Update.executeUpdate(); 143 Update.close(); 144 } 145 } catch (Exception e) { 146 e.printstacktrace(); 5

6 147 } 148 } public void Update_Account_Withdraw(Account account, Date date) { 151 // modify date_ as date, 15 // and modify account.withdraw_limitation_of_date_ as 153 // account.withdraw_limitation_per_day 154 try { 155 PreparedStatement Update; Update = con.preparestatement("update Account SET" " withdraw_limitation_of_date_ =" account.withdraw_limitation_per_day + ", date_ = #" new SimpleDateFormat("MM/dd/yyyy").format(date) + "#" " WHERE id = " + account.id + " "); 16 Update.executeUpdate(); Update.close(); 165 } catch (Exception e) { 166 e.printstacktrace(); 167 } 168 } public void Update_Account_Withdraw(Account account) { 171 // modify date_ as today, 17 // and modify account.withdraw_limitation_of_date_ as 173 // account.withdraw_limitation_per_day 174 this.update_account_withdraw(account, new Date()); 175 } 176 } * CallbackClient.java * 1 package ATM_Machine; 3 import java.rmi.remote; 4 import java.rmi.remoteexception; 5 import ATM_BasicClasses.Response; 6 7 public interface CallbackClient extends Remote { 8 public void receiveresponse(response response) throws RemoteException; 9 } * CallbackClientImpl.java * 1 package ATM_Machine; 3 import java.net.inetaddress; 4 import java.net.malformedurlexception; 5 import java.net.unknownhostexception; 6 import java.rmi.naming; 7 import java.rmi.server.unicastremoteobject; 8 import java.rmi.notboundexception; 6

7 9 import java.rmi.remoteexception; import ATM_BasicClasses.*; 1 import ATM_Server.CallbackServer; public class CallbackClientImpl implements CallbackClient { 15 private static nal String CALLBACK_CLIENT_SERVICE_NAME = "callbackclient"; private static nal String CALLBACK_SERVER_SERVICE_NAME = "callbackserver"; private static nal String CALLBACK_SERVER_MACHINE_NAME = "localhost"; 0 1 private Response response; 3 private boolean responseavailable; 4 5 public CallbackClientImpl() { 6 try { 7 UnicastRemoteObject.exportObject(this); 8 Naming.rebind(CALLBACK_CLIENT_SERVICE_NAME, this); 9 } catch (Exception exc) { 30 System.err 31.println("Error using RMI to register the CallbackClientImpl " 3 + exc); 33 } 34 } public void receiveresponse(response response) { 37 this.response = response; 38 this.responseavailable = true; 39 } public void sendcommand(command command) { 4 try { 43 String url = "//" + CALLBACK_SERVER_MACHINE_NAME + "/" 44 + CALLBACK_SERVER_SERVICE_NAME; 45 Object remoteserver = Naming.lookup(url); 46 if (remoteserver instanceof CallbackServer) { ((CallbackServer) remoteserver).execcommand(command, 49 InetAddress.getLocalHost().getHostName(), 50 CALLBACK_CLIENT_SERVICE_NAME); 51 } 5 responseavailable = false; 53 } catch (RemoteException exc) { 54 System.out.print(exc.toString()); 55 } catch (NotBoundException exc) { 56 } catch (MalformedURLException exc) { 57 } catch (UnknownHostException exc) { 58 } 59 } public Response getresponse() { 7

8 6 return response; 63 } public boolean isresponseavailable() { 66 return responseavailable; 67 } 68 } * GUI_MainFrame.java * 1 package ATM_Machine.GUI; 3 import javax.swing.jpanel; 4 import javax.swing.jframe; 5 import java.awt.gridlayout; 6 7 import javax.swing.jbutton; 8 9 import ATM_BasicClasses.*; public class GUI_MainFrame extends JFrame { 1 13 private static nal long serialversionuid = 1L; public JPanel jcontentpane = null; private JButton jbutton = null; private JButton jbutton1 = null; 0 1 private JButton jbutton = null; 3 private JButton jbutton3 = null; 4 5 private JButton jbutton4 = null; 6 7 private JButton jbutton5 = null; 8 9 public GUI_Withdraw_1_Insert_Card insert_card = new GUI_Withdraw_1_Insert_Card(); public GUI_Withdraw Input_Password input_password = new GUI_Withdraw Input_Password(); 3 33 public GUI_Withdraw_3_Input_Amount input_amount = new GUI_Withdraw_3_Input_Amount(); public GUI_Withdraw_4_Start_Withdraw start_withdraw = new GUI_Withdraw_4_Start_Withdraw(); public GUI_Withdraw_5_DisplayResult withdraw_result = new GUI_Withdraw_5_DisplayResult(); public GUI_ServiceUnavailable serviceunavailable = new GUI_ServiceUnavailable(); public Response response; 4 43 public Command command; 8

9 44 45 /** 46 * This is the default constructor 47 */ 48 public GUI_MainFrame() { 49 super(); 50 initialize(); 51 } 5 53 /** 54 * This method initializes this 55 * 56 void 57 */ 58 private void initialize() { this.setsize(338, 17); 61 this.setcontentpane(getjcontentpane()); 6 this.settitle("atm SERVICES"); 63 this.addwindowlistener(new java.awt.event.windowadapter() { 64 public void windowclosing(java.awt.event.windowevent e) { 65 System.out.println("windowClosing()"); 66 System.exit(0); 67 } 68 }); insert_card.setmainframe(this); 71 input_password.setmainframe(this); 7 input_amount.setmainframe(this); 73 start_withdraw.setmainframe(this); 74 withdraw_result.setmainframe(this); 75 serviceunavailable.setmainframe(this); 76 } /** 79 * This method initializes jcontentpane 80 * 81 javax.swing.jpanel 8 */ 83 private JPanel getjcontentpane() { 84 if (jcontentpane == null) { 85 GridLayout gridlayout = new GridLayout(); 86 gridlayout.setrows(3); 87 gridlayout.sethgap(0); 88 gridlayout.setvgap(0); 89 gridlayout.setcolumns(); 90 jcontentpane = new JPanel(); 91 jcontentpane.setlayout(gridlayout); 9 jcontentpane.add(getjbutton(), null); 93 jcontentpane.add(getjbutton1(), null); 94 jcontentpane.add(getjbutton(), null); 95 jcontentpane.add(getjbutton3(), null); 96 jcontentpane.add(getjbutton4(), null); 9

10 97 jcontentpane.add(getjbutton5(), null); 98 } 99 return jcontentpane; 100 } /** 103 * This method initializes jbutton 104 * 105 javax.swing.jbutton 106 */ 107 private JButton getjbutton() { 108 if (jbutton == null) { 109 jbutton = new JButton(); 110 jbutton.settext("withdraw"); 111 jbutton.addactionlistener(new java.awt.event.actionlistener() { 11 public void actionperformed(java.awt.event.actionevent e) { 113 withdrawservice(); 114 } 115 }); 116 } 117 return jbutton; 118 } /** 11 * This method initializes jbutton1 1 * 13 javax.swing.jbutton 14 */ 15 private JButton getjbutton1() { 16 if (jbutton1 == null) { 17 jbutton1 = new JButton(); 18 jbutton1.settext("deposit"); 19 jbutton1.addactionlistener(new java.awt.event.actionlistener() { 130 public void actionperformed(java.awt.event.actionevent e) { 131 depositservice(); 13 } 133 }); } 136 return jbutton1; 137 } /** 140 * This method initializes jbutton 141 * 14 javax.swing.jbutton 143 */ 144 private JButton getjbutton() { 145 if (jbutton == null) { 146 jbutton = new JButton(); 147 jbutton.settext("transfer"); 148 jbutton.addactionlistener(new java.awt.event.actionlistener() { 149 public void actionperformed(java.awt.event.actionevent e) { 10

11 150 transferservice(); 151 } 15 }); 153 } 154 return jbutton; 155 } /** 158 * This method initializes jbutton3 159 * 160 javax.swing.jbutton 161 */ 16 private JButton getjbutton3() { 163 if (jbutton3 == null) { 164 jbutton3 = new JButton(); 165 jbutton3.settext("change PASSWORD"); 166 jbutton3.addactionlistener(new java.awt.event.actionlistener() { 167 public void actionperformed(java.awt.event.actionevent e) { 168 changepassowrdservice(); } 171 }); 17 } 173 return jbutton3; 174 } /** 177 * This method initializes jbutton4 178 * 179 javax.swing.jbutton 180 */ 181 private JButton getjbutton4() { 18 if (jbutton4 == null) { 183 jbutton4 = new JButton(); 184 jbutton4.settext("inquire BALANCE"); 185 jbutton4.addactionlistener(new java.awt.event.actionlistener() { 186 public void actionperformed(java.awt.event.actionevent e) { 187 showbalanceservice(); } 190 }); 191 } 19 return jbutton4; 193 } /** 196 * This method initializes jbutton5 197 * 198 javax.swing.jbutton 199 */ 00 private JButton getjbutton5() { 01 if (jbutton5 == null) { 0 jbutton5 = new JButton(); 11

12 03 jbutton5.settext("print PASSBOOK"); 04 jbutton5.addactionlistener(new java.awt.event.actionlistener() { 05 public void actionperformed(java.awt.event.actionevent e) { 06 printpassbookservice(); } 09 }); 10 } 11 return jbutton5; 1 } private void withdrawservice() { 15 this.settitle("withdraw_service"); 16 this.setcontentpane(insert_card); 17 this.setvisible(true); 18 } 19 0 private void depositservice() { 1 this.settitle("warning!"); this.setcontentpane(serviceunavailable); 3 this.setvisible(true); 4 } 5 6 private void transferservice() { 7 this.settitle("warning!"); 8 this.setcontentpane(serviceunavailable); 9 this.setvisible(true); 30 } 31 3 private void changepassowrdservice() { 33 this.settitle("warning!"); 34 this.setcontentpane(serviceunavailable); 35 this.setvisible(true); 36 } private void showbalanceservice() { 39 this.settitle("warning!"); 40 this.setcontentpane(serviceunavailable); 41 this.setvisible(true); 4 } private void printpassbookservice() { 45 this.settitle("warning!"); 46 this.setcontentpane(serviceunavailable); 47 this.setvisible(true); 48 } } * GUI_ServiceUnavailable.java * 1 package ATM_Machine.GUI; 1

13 3 import javax.swing.jpanel; 4 import javax.swing.jlabel; 5 import javax.swing.jbutton; 6 import javax.swing.swingconstants; 7 import java.awt.font; 8 import java.awt.flowlayout; 9 10 public class GUI_ServiceUnavailable extends JPanel { 11 1 private static nal long serialversionuid = 1L; private JLabel jlabel = null; private JButton jbutton = null; private GUI_MainFrame mainframe; 19 0 /** 1 * This is the default constructor */ 3 public GUI_ServiceUnavailable() { 4 super(); 5 initialize(); 6 } 7 8 public void setmainframe(gui_mainframe mainframe) { 9 this.mainframe = mainframe; 30 } 31 3 /** 33 * This method initializes this 34 * 35 void 36 */ 37 private void initialize() { 38 FlowLayout owlayout = new FlowLayout(); 39 owlayout.sethgap(50); 40 owlayout.setvgap(50); 41 jlabel = new JLabel(); 4 43 jlabel.settext("sorry! The service is not available!"); 44 jlabel.setfont(new Font("Dialog", Font.ITALIC, 14)); 45 jlabel.sethorizontalalignment(swingconstants.center); 46 this.setlayout(owlayout); 47 this.setsize(318, 195); 48 this.add(jlabel, null); 49 this.add(getjbutton(), null); 50 } 51 5 /** 53 * This method initializes jbutton 54 * 55 javax.swing.jbutton 13

14 56 */ 57 private JButton getjbutton() { 58 if (jbutton == null) { 59 jbutton = new JButton(); 60 jbutton.settext("ok"); 61 jbutton.addactionlistener(new java.awt.event.actionlistener() { 6 public void actionperformed(java.awt.event.actionevent e) { 63 mainframe.settitle("atm SERVICES"); 64 if (mainframe.getcontentpane()!= mainframe.jcontentpane) 65 mainframe.setcontentpane(mainframe.jcontentpane); 66 } 67 }); 68 } 69 return jbutton; 70 } 71 7 } * GUI_Withdraw_1_Insert_Card.java * 1 package ATM_Machine.GUI; 3 import javax.swing.jpanel; 4 import javax.swing.jlabel; 5 import javax.swing.jbutton; 6 import javax.swing.swingconstants; 7 import java.awt.font; 8 import java.awt.flowlayout; 9 import javax.swing.jtextfield; 10 import java.awt.dimension; 11 1 public class GUI_Withdraw_1_Insert_Card extends JPanel { private static nal long serialversionuid = 1L; private JLabel jlabel = null; private JButton jbutton = null; 19 0 private JTextField jtextfield = null; 1 private JButton jbutton1 = null; 3 4 private long id = -1; 5 6 private GUI_MainFrame mainframe; 7 8 /** 9 * This is the default constructor 30 */ 31 public GUI_Withdraw_1_Insert_Card() { 3 super(); 33 initialize(); 14

15 34 } public void setmainframe(gui_mainframe mainframe) { 37 this.mainframe = mainframe; 38 } /** 41 * This method initializes this 4 * 43 void 44 */ 45 private void initialize() { 46 FlowLayout owlayout = new FlowLayout(); 47 owlayout.sethgap(50); 48 owlayout.setvgap(30); 49 jlabel = new JLabel(); jlabel.settext("please insert your card."); 5 jlabel.setfont(new Font("Dialog", Font.ITALIC, 14)); 53 jlabel.sethorizontalalignment(swingconstants.center); 54 this.setlayout(owlayout); 55 this.setsize(318, 195); 56 this.add(jlabel, null); 57 this.add(getjtextfield(), null); 58 this.add(getjbutton1(), null); 59 this.add(getjbutton(), null); 60 } 61 6 /** 63 * This method initializes jbutton 64 * 65 javax.swing.jbutton 66 */ 67 private JButton getjbutton() { 68 if (jbutton == null) { 69 jbutton = new JButton(); 70 jbutton.settext("next"); 71 jbutton.setenabled(false); 7 jbutton.setpreferredsize(new Dimension(84, 6)); 73 jbutton.addactionlistener(new java.awt.event.actionlistener() { 74 public void actionperformed(java.awt.event.actionevent e) { 75 try { 76 id = Long.parseLong(jTextField.getText()); 77 mainframe.setcontentpane(mainframe.input_password); 78 mainframe.setvisible(true); 79 } catch (NumberFormatException e1) { 80 setjtextfield(); 81 System.out 8.println("There exists a number format exception!"); 83 } 84 } 85 }); 86 } 15

16 87 return jbutton; 88 } /** 91 * This method initializes jtextfield 9 * 93 javax.swing.jtextfield 94 */ 95 private JTextField getjtextfield() { 96 if (jtextfield == null) { 97 jtextfield = new JTextField(); 98 jtextfield.settext(""); 99 jtextfield.setpreferredsize(new Dimension(00, 0)); 100 jtextfield.addkeylistener(new java.awt.event.keyadapter() { 101 public void keyreleased(java.awt.event.keyevent e) { 10 try { 103 Long.parseLong(jTextField.getText()); 104 jbutton.setenabled(true); 105 } catch (NumberFormatException e1) { 106 jbutton.setenabled(false); 107 } 108 } 109 }); 110 } 111 return jtextfield; 11 } public void setjtextfield() { 115 id = -1; 116 jtextfield.settext(""); 117 jbutton.setenabled(false); 118 } /** 11 * This method initializes jbutton1 1 * 13 javax.swing.jbutton 14 */ 15 private JButton getjbutton1() { 16 if (jbutton1 == null) { 17 jbutton1 = new JButton(); 18 jbutton1.settext("previous"); 19 jbutton1.addactionlistener(new java.awt.event.actionlistener() { 130 public void actionperformed(java.awt.event.actionevent e) { 131 setjtextfield(); mainframe.setcontentpane(mainframe.jcontentpane); 134 mainframe.setvisible(true); 135 } 136 }); 137 } 138 return jbutton1; 139 } 16

17 public long getid() { 14 return id; 143 } public void setid(long id) { 146 this.id = id; 147 } 148 } * GUI_Withdraw Input_Password.java * 1 package ATM_Machine.GUI; 3 import javax.swing.jpanel; 4 import javax.swing.jlabel; 5 import javax.swing.jbutton; 6 import javax.swing.swingconstants; 7 import java.awt.font; 8 import java.awt.flowlayout; 9 import java.awt.dimension; 10 import javax.swing.jpasswordfield; 11 1 public class GUI_Withdraw Input_Password extends JPanel { private static nal long serialversionuid = 1L; private JLabel jlabel = null; private JButton jbutton = null; 19 0 private JButton jbutton1 = null; 1 private JPasswordField jpasswordfield = null; 3 4 private int pass = -1; 5 6 private GUI_MainFrame mainframe; 7 8 /** 9 * This is the default constructor 30 */ 31 public GUI_Withdraw Input_Password() { 3 super(); 33 initialize(); 34 } public void setmainframe(gui_mainframe mainframe) { 37 this.mainframe = mainframe; 38 } /** 41 * This method initializes this 17

18 4 * 43 void 44 */ 45 private void initialize() { 46 FlowLayout owlayout = new FlowLayout(); 47 owlayout.sethgap(50); 48 owlayout.setvgap(30); 49 jlabel = new JLabel(); jlabel.settext("please input your password."); 5 jlabel.setfont(new Font("Dialog", Font.ITALIC, 14)); 53 jlabel.sethorizontalalignment(swingconstants.center); 54 this.setlayout(owlayout); 55 this.setsize(318, 195); 56 this.add(jlabel, null); 57 this.add(getjpasswordfield(), null); 58 this.add(getjbutton1(), null); 59 this.add(getjbutton(), null); 60 } 61 6 /** 63 * This method initializes jbutton 64 * 65 javax.swing.jbutton 66 */ 67 private JButton getjbutton() { 68 if (jbutton == null) { 69 jbutton = new JButton(); 70 jbutton.settext("next"); 71 jbutton.setenabled(false); 7 jbutton.setpreferredsize(new Dimension(84, 6)); 73 jbutton.addactionlistener(new java.awt.event.actionlistener() { 74 public void actionperformed(java.awt.event.actionevent e) { 75 try { 76 pass = Integer.parseInt(new String(jPasswordField 77.getPassword())); 78 mainframe.setcontentpane(mainframe.input_amount); 79 mainframe.setvisible(true); 80 } catch (NumberFormatException e1) { 81 setjpasswordfield(); 8 System.out 83.println("There exists a number format exception!"); 84 } } 87 }); 88 } 89 return jbutton; 90 } 91 9 /** 93 * This method initializes jbutton1 94 * 18

19 95 javax.swing.jbutton 96 */ 97 private JButton getjbutton1() { 98 if (jbutton1 == null) { 99 jbutton1 = new JButton(); 100 jbutton1.settext("previous"); 101 jbutton1.addactionlistener(new java.awt.event.actionlistener() { 10 public void actionperformed(java.awt.event.actionevent e) { 103 setjpasswordfield(); mainframe.setcontentpane(mainframe.insert_card); 106 mainframe.setvisible(true); 107 } 108 }); 109 } 110 return jbutton1; 111 } /** 114 * This method initializes jpasswordfield 115 * 116 javax.swing.jpasswordfield 117 */ 118 private JPasswordField getjpasswordfield() { 119 if (jpasswordfield == null) { 10 jpasswordfield = new JPasswordField(); 11 jpasswordfield.setpreferredsize(new Dimension(00, 0)); 1 jpasswordfield.addkeylistener(new java.awt.event.keyadapter() { 13 public void keyreleased(java.awt.event.keyevent e) { 14 try { 15 Integer.parseInt(new String(jPasswordField 16.getPassword())); 17 jbutton.setenabled(true); 18 } catch (NumberFormatException e1) { 19 jbutton.setenabled(false); 130 } 131 } 13 }); 133 } 134 return jpasswordfield; 135 } public void setjpasswordfield() { 138 pass = -1; 139 jpasswordfield.settext(""); 140 jbutton.setenabled(false); 141 } public int getpass() { 144 return pass; 145 } public void setpass(int pass) { 19

20 148 this.pass = pass; 149 } 150 } * GUI_Withdraw_3_Input_Amount.java * 1 package ATM_Machine.GUI; 3 import javax.swing.jpanel; 4 import javax.swing.jlabel; 5 import javax.swing.jbutton; 6 import javax.swing.swingconstants; 7 import java.awt.font; 8 import java.awt.flowlayout; 9 import javax.swing.jtextfield; 10 import java.awt.dimension; 11 1 public class GUI_Withdraw_3_Input_Amount extends JPanel { private static nal long serialversionuid = 1L; private JLabel jlabel = null; private JButton jbutton = null; 19 0 private JTextField jtextfield = null; 1 private JButton jbutton1 = null; 3 4 private int withdraw_amount = -1; 5 6 private GUI_MainFrame mainframe; 7 8 /** 9 * This is the default constructor 30 */ 31 public GUI_Withdraw_3_Input_Amount() { 3 super(); 33 initialize(); 34 } public void setmainframe(gui_mainframe mainframe) { 37 this.mainframe = mainframe; 38 } /** 41 * This method initializes this 4 * 43 void 44 */ 45 private void initialize() { 46 FlowLayout owlayout = new FlowLayout(); 47 owlayout.sethgap(50); 0

21 48 owlayout.setvgap(30); 49 jlabel = new JLabel(); jlabel.settext("please input the amount to withdraw."); 5 jlabel.setfont(new Font("Dialog", Font.ITALIC, 14)); 53 jlabel.sethorizontalalignment(swingconstants.center); this.setlayout(owlayout); 56 this.setsize(318, 195); 57 this.setbackground(null); 58 this.add(jlabel, null); 59 this.add(getjtextfield(), null); 60 this.add(getjbutton1(), null); 61 this.add(getjbutton(), null); 6 } /** 65 * This method initializes jbutton 66 * 67 javax.swing.jbutton 68 */ 69 private JButton getjbutton() { 70 if (jbutton == null) { 71 jbutton = new JButton(); 7 jbutton.settext("next"); 73 jbutton.setenabled(false); 74 jbutton.setpreferredsize(new Dimension(84, 6)); 75 jbutton.addactionlistener(new java.awt.event.actionlistener() { 76 public void actionperformed(java.awt.event.actionevent e) { 77 try { 78 withdraw_amount = Integer 79.parseInt(jTextField.getText()); 80 mainframe.start_withdraw 81.set_withdraw_amount(withdraw_amount); 8 mainframe.setcontentpane(mainframe.start_withdraw); } catch (NumberFormatException e1) { 85 setjtextfield(); 86 System.out 87.println("There exists a number format exception!"); 88 } } 91 }); 9 } 93 return jbutton; 94 } /** 97 * This method initializes jtextfield 98 * 99 javax.swing.jtextfield 100 */ 1

22 101 private JTextField getjtextfield() { 10 if (jtextfield == null) { 103 jtextfield = new JTextField(); 104 jtextfield.settext(""); 105 jtextfield.setpreferredsize(new Dimension(00, 0)); 106 jtextfield.addkeylistener(new java.awt.event.keyadapter() { 107 public void keyreleased(java.awt.event.keyevent e) { 108 try { 109 Integer.parseInt(jTextField.getText()); 110 jbutton.setenabled(true); 111 } catch (NumberFormatException e1) { 11 jbutton.setenabled(false); 113 } 114 } 115 }); 116 } 117 return jtextfield; 118 } public void setjtextfield() { 11 withdraw_amount = -1; 1 jbutton.setenabled(false); 13 jtextfield.settext(""); 14 } /** 17 * This method initializes jbutton1 18 * 19 javax.swing.jbutton 130 */ 131 private JButton getjbutton1() { 13 if (jbutton1 == null) { 133 jbutton1 = new JButton(); 134 jbutton1.settext("previous"); jbutton1.addactionlistener(new java.awt.event.actionlistener() { 137 public void actionperformed(java.awt.event.actionevent e) { 138 setjtextfield(); mainframe.setcontentpane(mainframe.input_password); 141 mainframe.setvisible(true); 14 } 143 }); 144 } 145 return jbutton1; 146 } public int getwithdrawamount() { 149 return withdraw_amount; 150 } public void setwithdrawamount(int withdraw_amount) { 153 this.withdraw_amount = withdraw_amount;

23 154 } } * GUI_Withdraw_4_Start_Withdraw.java * 1 package ATM_Machine.GUI; 3 import javax.swing.jpanel; 4 import javax.swing.jlabel; 5 import javax.swing.jbutton; 6 import javax.swing.swingconstants; 7 8 import ATM_BasicClasses.Command_Withdraw; 9 import ATM_BasicClasses.Response_Withdraw; 10 import ATM_Machine.Operation; 11 1 import java.awt.font; 13 import java.awt.flowlayout; 14 import ATM_Machine.Resources.*; public class GUI_Withdraw_4_Start_Withdraw extends JPanel { private static nal long serialversionuid = 1L; 19 0 private JLabel jlabel = null; 1 private JButton jbutton = null; 3 4 private JButton jbutton1 = null; 5 6 private GUI_MainFrame mainframe; 7 8 /** 9 * This is the default constructor 30 */ 31 public GUI_Withdraw_4_Start_Withdraw() { 3 super(); 33 initialize(); 34 } public void setmainframe(gui_mainframe mainframe) { 37 this.mainframe = mainframe; 38 } /** 41 * This method initializes this 4 * 43 void 44 */ 45 private void initialize() { 46 FlowLayout owlayout = new FlowLayout(); 47 owlayout.sethgap(50); 3

24 48 owlayout.setvgap(50); 49 jlabel = new JLabel(); jlabel 5.setText("<html>You want to withdraw *** Japanese Yen,<br> are you sure?</html>"); 53 jlabel.setfont(new Font("Dialog", Font.ITALIC, 14)); 54 jlabel.sethorizontalalignment(swingconstants.center); 55 this.setlayout(owlayout); 56 this.setsize(318, 195); 57 this.add(jlabel, null); 58 this.add(getjbutton(), null); 59 this.add(getjbutton1(), null); 60 } 61 6 public void set_withdraw_amount(int amount) { 63 jlabel.settext("<html>you want to withdraw " + amount 64 + " Japanese Yen,<br> are you sure?</html>"); 65 } /** 68 * This method initializes jbutton 69 * 70 javax.swing.jbutton 71 */ 7 private JButton getjbutton() { 73 if (jbutton == null) { 74 jbutton = new JButton(); 75 jbutton.settext("yes"); 76 jbutton.addactionlistener(new java.awt.event.actionlistener() { 77 public void actionperformed(java.awt.event.actionevent e) { 78 long id; 79 int pass; 80 int withdraw_amount; 81 8 id = mainframe.insert_card.getid(); 83 pass = mainframe.input_password.getpass(); 84 withdraw_amount = mainframe.input_amount 85.getWithdrawAmount(); // We may check the command here. 88 mainframe.command = new Command_Withdraw(id, pass, 89 withdraw_amount); 90 mainframe.response = Operation 91.start_operation(mainframe.command); 9 93 displayresponse(); 94 } 95 }); } 98 return jbutton; 99 } 100 4

25 101 private void displayresponse() { 10 if (mainframe.response instanceof Response_Withdraw) { String resultmsg; 105 switch (((Response_Withdraw) mainframe.response).success_or_fail) { 106 case 0: 107 int cash = ((ATM_BasicClasses.Command_Withdraw) mainframe.command).withdraw_amount; 108 resultmsg = "You successfully withdraw " + cash " Japanese Yen."; 110 break; 111 case 1: 11 resultmsg = Error_Msg.error_msg_001; 113 break; 114 case : 115 resultmsg = Error_Msg.error_msg_00; 116 break; 117 case 3: 118 resultmsg = Error_Msg.error_msg_003; 119 break; 10 default: 11 resultmsg = Error_Msg.error_msg_004; 1 } 13 mainframe.withdraw_result.set_text_for_jlabel(resultmsg); 14 mainframe.setcontentpane(mainframe.withdraw_result); 15 } 16 } /** 19 * This method initializes jbutton1 130 * 131 javax.swing.jbutton 13 */ 133 private JButton getjbutton1() { 134 if (jbutton1 == null) { 135 jbutton1 = new JButton(); 136 jbutton1.settext("no"); 137 jbutton1.addactionlistener(new java.awt.event.actionlistener() { 138 public void actionperformed(java.awt.event.actionevent e) { 139 mainframe.setcontentpane(mainframe.input_amount); 140 } 141 }); 14 } 143 return jbutton1; 144 } } * GUI_Withdraw_5_DisplayResult.java * 1 package ATM_Machine.GUI; 3 import javax.swing.jpanel; 4 import javax.swing.jlabel; 5

26 5 import javax.swing.jbutton; 6 import javax.swing.swingconstants; 7 8 import ATM_BasicClasses.Response_Withdraw; 9 10 import java.awt.font; 11 import java.awt.flowlayout; 1 13 public class GUI_Withdraw_5_DisplayResult extends JPanel { private static nal long serialversionuid = 1L; private JLabel jlabel = null; private JButton jbutton = null; 0 1 private GUI_MainFrame mainframe; 3 /** 4 * This is the default constructor 5 */ 6 public GUI_Withdraw_5_DisplayResult() { 7 super(); 8 initialize(); 9 } /** 3 * This method initializes this 33 * 34 void 35 */ 36 public void setmainframe(gui_mainframe mainframe) { 37 this.mainframe = mainframe; 38 } private void initialize() { 41 FlowLayout owlayout = new FlowLayout(); 4 owlayout.sethgap(50); 43 owlayout.setvgap(50); 44 jlabel = new JLabel(); jlabel.settext("withdraw_result!"); 47 jlabel.setfont(new Font("Dialog", Font.ITALIC, 14)); 48 jlabel.sethorizontalalignment(swingconstants.center); 49 this.setlayout(owlayout); 50 this.setsize(318, 195); 51 this.add(jlabel, null); 5 this.add(getjbutton(), null); 53 } /** 56 * This method initializes jbutton 57 * 6

27 58 javax.swing.jbutton 59 */ 60 private JButton getjbutton() { 61 if (jbutton == null) { 6 jbutton = new JButton(); 63 jbutton.settext("ok"); 64 jbutton.addactionlistener(new java.awt.event.actionlistener() { 65 public void actionperformed(java.awt.event.actionevent e) { 66 switch (((Response_Withdraw) mainframe.response).success_or_fail) { 67 case 1: 68 case 3: 69 mainframe.settitle("withdraw_services"); 70 if (mainframe.getcontentpane()!= mainframe.input_amount) 71 mainframe.setcontentpane(mainframe.input_amount); 7 mainframe.input_amount.setjtextfield(); 73 break; 74 default: 75 mainframe.settitle("atm SERVICES"); 76 mainframe.insert_card.setjtextfield(); 77 mainframe.input_password.setjpasswordfield(); 78 mainframe.input_amount.setjtextfield(); 79 if (mainframe.getcontentpane()!= mainframe.jcontentpane) 80 mainframe.setcontentpane(mainframe.jcontentpane); 81 } 8 } 83 }); 84 } 85 return jbutton; 86 } public void set_text_for_jlabel(string string) { 89 jlabel.settext(string); 90 } 91 9 } * Operation.java * 1 package ATM_Machine; 3 import ATM_BasicClasses.Command; 4 import ATM_BasicClasses.Response; 5 6 public class Operation { 7 public static Response start_operation(command command) { 8 CallbackClientImpl callbackclient = new CallbackClientImpl(); 9 callbackclient.sendcommand(command); try { 1 while (!callbackclient.isresponseavailable()) { 13 System.out 14.println("Response is not available yet; sleeping for seconds"); 15 Thread.sleep(000); 7

28 16 } 17 } catch (InterruptedException exc) { 18 } 19 0 return callbackclient.getresponse(); 1 } } * Display_Labels.java * 1 package ATM_Machine.Resources; 3 public enum Display_Labels { 4 5 } * Error_Msg.java * 1 package ATM_Machine.Resources; 3 public class Error_Msg { 4 5 public nal static String error_msg_001 = "Your requested amount is too large."; 6 7 public nal static String error_msg_00 = "Your id/pass is wrong."; 8 9 public nal static String error_msg_003 = "Your requested amount is over the limitation per day."; public nal static String error_msg_004 = "You fail to withdraw your cash for unknown reasons!"; 1 } * Success_Msg.java * 1 package ATM_Machine.Resources; 3 public enum Success_Msg { 4 5 } * CallbackServer.java * 1 package ATM_Server; 3 import java.rmi.remote; 4 import java.rmi.remoteexception; 5 import ATM_BasicClasses.Command; 6 7 public interface CallbackServer extends Remote { 8 public void execcommand(command command, String callbackmachine, 9 String callbackobjectname) throws RemoteException; 10 } * CallbackServerDelegate.java * 8

29 1 package ATM_Server; 3 import java.net.malformedurlexception; 4 import java.rmi.naming; 5 import java.rmi.notboundexception; 6 import java.rmi.remoteexception; 7 import ATM_BasicClasses.*; 8 import ATM_Database.Accounts; 9 import ATM_Machine.CallbackClient; 10 import java.util.date; 11 import java.text.simpledateformat; 1 13 public class CallbackServerDelegate implements Runnable { 14 private Thread processingthread; private Command command; private String callbackmachine; 19 0 private String callbackobjectname; 1 public CallbackServerDelegate(Command newcommand, 3 String newcallbackmachine, String newcallbackobjectname) { 4 5 command = newcommand; 6 callbackmachine = newcallbackmachine; 7 callbackobjectname = newcallbackobjectname; 8 processingthread = new Thread(this); 9 processingthread.start(); 30 } 31 3 public void run() { 33 Response response = produceresponse(command); 34 sendresponsetoclient(response); 35 } private Response produceresponse(command command) {// start operation and 38 // produce a response 39 if (command instanceof Command_Withdraw) { 40 Response_Withdraw response_withdraw; 41 4 Accounts accounts = new Accounts(); FoundAccount R = accounts.search_account( 45 ((Command_Withdraw) command).id, 46 ((Command_Withdraw) command).password); if (R.found) { Date date = new Date(); 51 SimpleDateFormat date_with_format = new SimpleDateFormat( 5 "MM/dd/yyyy"); 9

30 { if (!date_with_format.format(date).equals( 55 date_with_format.format(r.account.date_))) { 56 accounts.update_account_withdraw(r.account);// update the 57 // withdrawlimitation 58 // and date 59 accounts.releaseconnection(); 60 response_withdraw = (Response_Withdraw) produceresponse(command); 61 } else if (R.account.balance >= ((Command_Withdraw) command).withdraw_amount 6 && R.account.withdraw_limitation_of_date_ >= ((Command_Withdraw) command).withdraw_amo 63 accounts.update_account_withdraw(r.account, 64 ((Command_Withdraw) command).withdraw_amount); 65 response_withdraw = new Response_Withdraw(0); 66 } else if (R.account.balance < ((Command_Withdraw) command).withdraw_amount) { 67 response_withdraw = new Response_Withdraw(1); 68 } else { 69 response_withdraw = new Response_Withdraw(3); 70 } 71 } else 7 response_withdraw = new Response_Withdraw(); accounts.releaseconnection(); return response_withdraw; 77 } else 78 return new Response(); 79 } private void sendresponsetoclient(response response) { 8 try { String url = "//" + callbackmachine + "/" + callbackobjectname; 85 Object remoteclient = Naming.lookup(url); if (remoteclient instanceof CallbackClient) { 88 ((CallbackClient) remoteclient).receiveresponse(response); 89 } 90 } catch (RemoteException exc) { 91 } catch (NotBoundException exc) { 9 } catch (MalformedURLException exc) { 93 } 94 } 95 } * CallbackServerImpl.java * 1 package ATM_Server; 3 import java.rmi.naming; 4 import java.rmi.server.unicastremoteobject; 5 import ATM_BasicClasses.Command; 6 30

31 7 public class CallbackServerImpl implements CallbackServer { 8 private static nal String CALLBACK_SERVER_SERVICE_NAME = "callbackserver"; 9 10 public CallbackServerImpl() { 11 try { 1 UnicastRemoteObject.exportObject(this); 13 Naming.rebind(CALLBACK_SERVER_SERVICE_NAME, this); 14 } catch (Exception exc) { 15 System.err 16.println("Error using RMI to register the CallbackServerImpl " 17 + exc); 18 } 19 } 0 1 public void execcommand(command command, String callbackmachine, String callbackobjectname) { 3 new CallbackServerDelegate(command, callbackmachine, callbackobjectname); 4 } 5 } * Run_Server_and_Client.java * 1 package Main; 3 import java.io.ioexception; 4 import ATM_Server.CallbackServerImpl; 5 import ATM_Machine.GUI.GUI_MainFrame; 6 7 public class Run_Server_and_Client { 8 9 /** 10 args 11 */ 1 13 public static void main(string[] args) { 14 // TODO Auto-generated method stub System.out.println("Running the RMI compiler (rmic)"); 17 System.out.println(); 18 try { 19 Process p1 = Runtime 0.getRuntime() 1.exec( "C:nnProgram FilesnnJavannjdk1.5.0_09nnbinnnrmic ATM_Server.CallbackServerImpl"); 3 Process p = Runtime 4.getRuntime() 5.exec( 6 "C:nnProgram FilesnnJavannjdk1.5.0_09nnbinnnrmic ATM_Machine.CallbackClientImpl"); 7 p1.waitfor(); 8 p.waitfor(); 9 } catch (IOException exc) { 30 System.err 31.println("Unable to run rmic utility. Exiting application."); 31

32 3 System.exit(1); 33 } catch (InterruptedException exc) { 34 System.err 35.println("Threading problems encountered while using the rmic utility."); 36 } System.out.println("Starting the rmiregistry"); 39 System.out.println(); 40 Process rmiprocess = null; 41 try { 4 rmiprocess = Runtime.getRuntime().exec("rmiregistry"); 43 Thread.sleep(3000); 44 } catch (IOException exc) { 45 System.err 46.println("Unable to start the rmiregistry. Exiting application."); 47 System.exit(1); 48 } catch (InterruptedException exc) { 49 System.err 50.println("Threading problems encountered when starting the rmiregistry."); 51 } 5 53 System.out.println("Creating the client and server objects"); 54 System.out.println(); CallbackServerImpl callbackserver = new CallbackServerImpl(); new GUI_MainFrame().setVisible(true); 59 } } 3

This document shows a simpli ed version of the 7 paths derived from the program implementing the Withdraw operation speci cation.

This document shows a simpli ed version of the 7 paths derived from the program implementing the Withdraw operation speci cation. This document shows a simpli ed version of the 7 paths derived from the program implementing the Withdraw operation speci cation. Path 0... 76 jbutton.addactionlistener(new java.awt.event.actionlistener()

More information

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course

JAC444 - Lecture 11. Remote Method Invocation Segment 2 - Develop RMI Application. Jordan Anastasiade Java Programming Language Course JAC444 - Lecture 11 Remote Method Invocation Segment 2 - Develop RMI Application 1 Remote Method Invocation In this lesson you will be learning about: Designing RMI application Developing distributed object

More information

SampleApp.java. Page 1

SampleApp.java. Page 1 SampleApp.java 1 package msoe.se2030.sequence; 2 3 /** 4 * This app creates a UI and processes data 5 * @author hornick 6 */ 7 public class SampleApp { 8 private UserInterface ui; // the UI for this program

More information

AppBisect > PrBisect > class Functie. AppBisect > PrBisect > class Punct. public class Functie { double x(double t) { return t;

AppBisect > PrBisect > class Functie. AppBisect > PrBisect > class Punct. public class Functie { double x(double t) { return t; 1 AppBisect > PrBisect > class Punct public class Punct { double x,y; public Punct(double x, double y) { this.x = x; this.y = y; public void setx(double x) { this.x = x; public double getx() { return x;

More information

COMP16121 Sample Code Lecture 1

COMP16121 Sample Code Lecture 1 COMP16121 Sample Code Lecture 1 Sean Bechhofer, University of Manchester, Manchester, UK sean.bechhofer@manchester.ac.uk 1 SimpleFrame 1 import javax.swing.jframe; 2 3 public class SimpleFrame { 4 5 /*

More information

jlabel14 = new javax.swing.jlabel(); jlabel15 = new javax.swing.jlabel(); jlabel16 = new javax.swing.jlabel(); jlabel17 = new javax.swing.

jlabel14 = new javax.swing.jlabel(); jlabel15 = new javax.swing.jlabel(); jlabel16 = new javax.swing.jlabel(); jlabel17 = new javax.swing. 188 APPENDIX 1 { jinternalframe1 = new javax.swing.jinternalframe(); jlabel1 = new javax.swing.jlabel(); jlabel2 = new javax.swing.jlabel(); jlabel3 = new javax.swing.jlabel(); jlabel4 = new javax.swing.jlabel();

More information

Answer on question #61311, Programming & Computer Science / Java

Answer on question #61311, Programming & Computer Science / Java Answer on question #61311, Programming & Computer Science / Java JSP JSF for completion Once the user starts the thread by clicking a button, the program must choose a random image out of an image array,

More information

RMI. (Remote Method Invocation)

RMI. (Remote Method Invocation) RMI (Remote Method Invocation) Topics What is RMI? Why RMI? Architectural components Serialization & Marshaled Objects Dynamic class loading Code movement Codebase ClassLoader delegation RMI Security Writing

More information

// autor igre Ivan Programerska sekcija package mine;

// autor igre Ivan Programerska sekcija package mine; // autor igre Ivan Bauk @ Programerska sekcija package mine; import java.awt.color; import java.awt.flowlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

Java Programming Summer 2008 LAB. Thursday 8/21/2008

Java Programming Summer 2008 LAB. Thursday 8/21/2008 LAB Thursday 8/21/2008 Design and implement the program that contains a timer. When the program starts, the timer shows 00:00:00. When we click the Start button, the timer starts. When we click the Stop

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the

More information

1 interface TemperatureSensor extends java.rmi.remote 2 { 3 public double gettemperature() throws java.rmi.remoteexception; 4 public void

1 interface TemperatureSensor extends java.rmi.remote 2 { 3 public double gettemperature() throws java.rmi.remoteexception; 4 public void 1 interface TemperatureSensor extends java.rmi.remote 2 { 3 public double gettemperature() throws java.rmi.remoteexception; 4 public void addtemperaturelistener ( TemperatureListener listener ) 5 throws

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan

More information

JAVA RMI. Remote Method Invocation

JAVA RMI. Remote Method Invocation 1 JAVA RMI Remote Method Invocation 2 Overview Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space. The other address space could be: On the same

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod

More information

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Network. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark Network Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Outline Socket programming If we have the time: Remote method invocation (RMI) 2 Socket Programming Sockets

More information

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP)

55:182/22C:182. Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP) 55:182/22C:182 Distributed Application Frameworks Java RMI, CORBA, Web Services (SOAP) Broker Architecture Example Java Remote Method Invocation (RMI) Invoking a method which lies in a different address

More information

Lampiran A. SOURCE CODE PROGRAM

Lampiran A. SOURCE CODE PROGRAM A-1 Lampiran A. SOURCE CODE PROGRAM Frame Utama package FrameDesign; import ArithmeticSkripsi.ArithmeticCompress; import ArithmeticSkripsi.ArithmeticDecompress; import Deflate.DeflateContoh; import java.io.file;

More information

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2009 FINAL EXAMINATION 14 DECEMBER 2009 Instructor: Alan McLeod If the instructor is unavailable

More information

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords Goals By the end of this lesson, you should: Lecture 7 More GUI programming 1. Be able to write Java s with JTextField, JList, JCheckBox and JRadioButton components 2. Be able to implement a ButtonGroup

More information

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017

Distributed Systems. 02r. Java RMI Programming Tutorial. Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017 Distributed Systems 02r. Java RMI Programming Tutorial Paul Krzyzanowski TA: Long Zhao Rutgers University Fall 2017 1 Java RMI RMI = Remote Method Invocation Allows a method to be invoked that resides

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod

More information

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A

Contents. Java RMI. Java RMI. Java RMI system elements. Example application processes/machines Client machine Process/Application A Contents Java RMI G53ACC Chris Greenhalgh Java RMI overview A Java RMI example Overview Walk-through Implementation notes Argument passing File requirements RPC issues and RMI Other problems with RMI 1

More information

* To change this license header, choose License Headers in Project Properties.

* To change this license header, choose License Headers in Project Properties. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools Templates * and open the template in the editor. package tugasumbyjava; /**

More information

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

JRadioButton account_type_radio_button2 = new JRadioButton(Current); ButtonGroup account_type_button_group = new ButtonGroup(); Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button

More information

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2012 FINAL EXAMINATION 9am to 12pm, 26 APRIL 2012 Instructor: Alan McLeod If the instructor is

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2008 FINAL EXAMINATION 7pm to 10pm, 17 DECEMBER 2008, Grant Hall Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2010 FINAL EXAMINATION 11 DECEMBER 2010, 9am SOLUTION HAND IN Answers Are Recorded on Question Paper Instructor: Alan McLeod If the instructor

More information

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split DAFTAR LAMPIRAN Source Code Java Aplikasi Keyword to Image Renamer Split Source Code Menu Utama package spin_text; import java.awt.color; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing

Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/

More information

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau List of Slides 1 Title 2 Chapter 13: Graphical user interfaces 3 Chapter aims 4 Section 2: Example:Hello world with a GUI 5 Aim 6 Hello world with a GUI 7 Hello world with a GUI 8 Package: java.awt and

More information

CreateServlet.java

CreateServlet.java Classes in OBAAS 1.2: -------------------- The package name is pack_bank. Create this package in java source of your project. Create classes as per the class names provided here. You can then copy the

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2009 FINAL EXAMINATION 14 DECEMBER 2009 SOLUTION Instructor: Alan McLeod If the instructor is unavailable

More information

RMI Example RMI. CmpE 473 Internet Programming RMI

RMI Example RMI. CmpE 473 Internet Programming RMI CmpE 473 Internet Programming Pınar Yolum pinar.yolum@boun.edu.tr Department of Computer Engineering Boğaziçi University RMI Examples from Advanced Java: Internet Applications, Art Gittleman Remote Method

More information

Remote Procedure Call

Remote Procedure Call Remote Procedure Call Suited for Client-Server structure. Combines aspects of monitors and synchronous message passing: Module (remote object) exports operations, invoked with call. call blocks (delays

More information

CSE 530A. DAOs and MVC. Washington University Fall 2012

CSE 530A. DAOs and MVC. Washington University Fall 2012 CSE 530A DAOs and MVC Washington University Fall 2012 Model Object Example public class User { private Long id; private String username; private String password; public Long getid() { return id; public

More information

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2) Introduction Objective To support interoperability and portability of distributed OO applications by provision of enabling technology Object interaction vs RPC Java Remote Method Invocation (RMI) RMI Registry

More information

package As7BattleShip;

package As7BattleShip; package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Runs the battleship game Input: ship placement board files and computer player type Output:

More information

APPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }

APPENDIX. public void cekroot() { System.out.println(nilai root : +root.data); } APPENDIX CLASS NODE AS TREE OBJECT public class Node public int data; public Node left; public Node right; public Node parent; public Node(int i) data=i; PROCEDURE BUILDING TREE public class Tree public

More information

import java.applet.applet; import java.applet.audioclip; import java.net.url; public class Vjesala2 {

import java.applet.applet; import java.applet.audioclip; import java.net.url; public class Vjesala2 { import java.awt.color; import java.awt.flowlayout; import java.awt.font; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton;

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod If the

More information

#,!" $* ( #+,$ $$ $# -.,$ / 0' ".12 $ $$ 5/ #$" " " $ $ " # $ / 4 * # 6/ 8$8 ' # 6 $! 6$$ #$ * $ $$ ** 4 # 6 # * 0; & *! # #! #(' 7 / $#$ -.

#,! $* ( #+,$ $$ $# -.,$ / 0' .12 $ $$ 5/ #$   $ $  # $ / 4 * # 6/ 8$8 ' # 6 $! 6$$ #$ * $ $$ ** 4 # 6 # * 0; & *! # #! #(' 7 / $#$ -. ! " $ %&(& $ $ $* ( +,$ $$ $ -.,$ / 0 ".12 ) ($$ ( 4, /!" ($$ ( 4, / 4 0 ($ $ $ $ $$ 5/ $" " " $ $ " $ / 4 * %!&& $ $$ ** 4 6 7$ 4 0 %!&& $ 88 $ 6 67 $ / ** 7$ 4.12 )*&$& 6/ 8$8 6 $! 6$$ $ * 67$ : $* $

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod If

More information

Remote Method Invocation

Remote Method Invocation Remote Method Invocation RMI Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in 1 Agenda Introduction Creating

More information

Java Programming Language Advance Feature

Java Programming Language Advance Feature Java Programming Language Advance Feature Peter.Cheng founder_chen@yahoo.com.cn http://www.huihoo.com 2004-04 Huihoo - Enterprise Open Source http://www.huihoo.com 1 Course Goal The main goal of this course

More information

Generic architecture

Generic architecture Java-RMI Lab Outline Let first builds a simple home-made framework This is useful to understand the main issues We see later how java-rmi works and how it solves the same issues Generic architecture object

More information

CSci Introduction to Distributed Systems. Communication: RPC In Practice

CSci Introduction to Distributed Systems. Communication: RPC In Practice CSci 5105 Introduction to Distributed Systems Communication: RPC In Practice Linux RPC Language-neutral RPC Can use Fortran, C, C++ IDL compiler rpgen N to generate all stubs, skeletons (server stub) Example:

More information

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

03 Remote invocation. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI 03 Remote invocation Request-reply RPC Coulouris 5 Birrel_Nelson_84.pdf RMI 2/16 Remote Procedure Call Implementation client process Request server process client program client stub procedure Communication

More information

Last Class: Network Overview. Today: Distributed Systems

Last Class: Network Overview. Today: Distributed Systems Last Class: Network Overview =>Processes in a distributed system all communicate via a message exchange. Physical reality: packets Abstraction: messages limited size arbitrary size unordered (sometimes)

More information

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9,

Distributed Systems. Distributed Object Systems 2 Java RMI. Java RMI. Example. Applet continued. Applet. slides2.pdf Sep 9, Distributed Object Systems 2 Java RMI Piet van Oostrum Distributed Systems What should a distributed system provide? Illusion of one system while running on multiple systems Transparancy Issues Communication,

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable

More information

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4 EEC-681/781 Distributed Computing Systems Lecture 4 Department of Electrical and Computer Engineering Cleveland State University wenbing@ieee.org Outline Inter-process communications Computer networks

More information

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full

More information

Remote Method Invocation

Remote Method Invocation Remote Method Invocation A true distributed computing application interface for Java, written to provide easy access to objects existing on remote virtual machines Provide access to objects existing on

More information

* To change this license header, choose License Headers in Project Properties.

* To change this license header, choose License Headers in Project Properties. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools Templates * and open the template in the editor. */ package calci; /** * *

More information

Swing - JTextField. Adding a text field to the main window (with tooltips and all)

Swing - JTextField. Adding a text field to the main window (with tooltips and all) Swing - JTextField Adding a text field to the main window (with tooltips and all) Prerequisites - before this lecture You should have seen: The lecture on JFrame The lecture on JButton Including having

More information

Distributed Computing

Distributed Computing Distributed Computing Computing on many systems to solve one problem Why? - Combination of cheap processors often more cost-effective than one expensive fast system - Flexibility to add according to needs

More information

COMPSCI 230 Threading Week8. Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/]

COMPSCI 230 Threading Week8. Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/] COMPSCI 230 Threading Week8 Figure 1 Thread status diagram [http://www.programcreek.com/2009/03/thread-status/] Synchronization Lock DeadLock Why do we need Synchronization in Java? If your code is executing

More information

PlaniSphere. Creating a plug-in for PlaniSphere.

PlaniSphere. Creating a plug-in for PlaniSphere. Creating a plug-in for PlaniSphere Creating a plug-in requires a developer to implement SpatialPlugin and SpatialPluginFrame interfaces (see Figure 1). The SpatialPlugin interface defines methods that

More information

RMI Case Study. A Typical RMI Application

RMI Case Study. A Typical RMI Application RMI Case Study This example taken directly from the Java RMI tutorial http://java.sun.com/docs/books/tutorial/rmi/ Editorial note: Please do yourself a favor and work through the tutorial yourself If you

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity PROGRAMMING Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda PreparedStatement

More information

/** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box }

/** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box } /* * To change this template, choose Tools Templates * and open the template in the editor. */ /* * NewJFrame.java * * Created on Apr 17, 2011, 1:13:13 PM */ /** * * @author Kelli */ import java.io.*;

More information

!"# $ %&# %####' #&() % # # # #&* # ## +, # -

!# $ %&# %####' #&() % # # # #&* # ## +, # - By Pep Jorge @joseplluisjorge Steema Software July 213!"# $ %&# %####' #&() % # # # #&* # ## +, # -. / " - $- * 11 1 1$ 2 11 1 3 4 / $ 5 5,+67 +68$ Copyright 213 Steema Software SL. Copyright Information.

More information

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine.

Questions and Answers. A. RMI allows us to invoke a method of java object that executes on another machine. Q.1) What is Remote method invocation (RMI)? A. RMI allows us to invoke a method of java object that executes on another machine. B. RMI allows us to invoke a method of java object that executes on another

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate

More information

Eclipsing Your IDE. Figure 1 The first Eclipse screen.

Eclipsing Your IDE. Figure 1 The first Eclipse screen. Eclipsing Your IDE James W. Cooper I have been hearing about the Eclipse project for some months, and decided I had to take some time to play around with it. Eclipse is a development project (www.eclipse.org)

More information

IBD Intergiciels et Bases de Données

IBD Intergiciels et Bases de Données IBD Intergiciels et Bases de Données RMI-based distributed systems Fabien Gaud, Fabien.Gaud@inrialpes.fr Overview of lectures and practical work Lectures Introduction to distributed systems and middleware

More information

RAIK 183H Examination 2 Solution. November 10, 2014

RAIK 183H Examination 2 Solution. November 10, 2014 RAIK 183H Examination 2 Solution November 10, 2014 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

More information

Chapter 10 Inheritance. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved.

Chapter 10 Inheritance. Big Java by Cay Horstmann Copyright 2009 by John Wiley & Sons. All rights reserved. Chapter 10 Inheritance Chapter Goals To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package

More information

Designing an Interactive Jini Service

Designing an Interactive Jini Service Chap04.fm Page 96 Tuesday, May 22, 2001 3:11 PM Designing an Interactive Jini Service Topics in This Chapter Designing distributed services The importance of interfaces in defining services Using utility

More information

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling

Handout 14 Graphical User Interface (GUI) with Swing, Event Handling Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement

More information

Midterm assessment - MAKEUP Fall 2010

Midterm assessment - MAKEUP Fall 2010 M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:

More information

JAVA CODE JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS PAGE 1

JAVA CODE JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS PAGE 1 CODE JAVA CODE BINOMIAL TREES OPTION PRICING JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS /** * * @author Ioannis Svigkos 2008 */ // This class corresponds to binomial tree option pricing.

More information

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development:

RMI (Remote Method Invocation) Over the year, there have been 3 different approaches to application development: RMI (Remote Method Invocation) History: Over the year, there have been 3 different approaches to application development: 1. the traditional approach. 2. the client / server approach and 3. the component-

More information

BSc ( Hons) Computer Science with Network Security. Examinations for / Semester 2

BSc ( Hons) Computer Science with Network Security. Examinations for / Semester 2 BSc ( Hons) Computer Science with Network Security Cohort: BCNS/16B/FT Examinations for 2017 2018 / Semester 2 Resit Examinations for BCNS/15B/FT & BCNS/16A/FT MODULE: NETWORK PROGRAMMING MODULE CODE:

More information

COMP16121 Notes on Mock Exam Questions

COMP16121 Notes on Mock Exam Questions COMP16121 Notes on Mock Exam Questions December 2016 Mock Exam Attached you will find a Mock multiple choice question (MCQ) exam for COMP16121, to assist you in preparing for the actual COMP16121 MCQ Exam

More information

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features: Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of

More information

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners

GUI (Graphic User Interface) Programming. Part 2 (Chapter 8) Chapter Goals. Events, Event Sources, and Event Listeners. Listeners GUI (Graphic User Interface) Programming Part 2 (Chapter 8) Chapter Goals To understand the Java event model To install action and mouse event listeners To accept input from buttons, text fields, and the

More information

Complimentary material for the book Software Engineering in the Agile World

Complimentary material for the book Software Engineering in the Agile World Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-93-5300-898-7) published by Amazon, USA (ISBN: 978-1976901751) and Flushing Meadows Publishers, India (ISBN: 978-93-5300-898-7)

More information

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University CS 555: DISTRIBUTED SYSTEMS [RMI] Frequently asked questions from the previous class survey Shrideep Pallickara Computer Science Colorado State University L21.1 L21.2 Topics covered in this lecture RMI

More information

EAST WEST UNIVERSITY

EAST WEST UNIVERSITY EAST WEST UNIVERSITY RMI Based Distributed Query Processing Submitted By Avirupa Roy Talukder ID: 2011-2-60-001 Alok Kumar Roy ID: 2011-2-60-045 Supervised by Dr. Shamim Akhter Assistant Professor Department

More information

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015 CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 5 problems on the following 7 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet

More information

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008 Overview Lecture 7: Inheritance and GUIs Written by: Daniel Dalevi Inheritance Subclasses and superclasses Java keywords Interfaces and inheritance The JComponent class Casting The cosmic superclass Object

More information

Java Never Ends MULTITHREADING 958 Example: A Nonresponsive GUI 959

Java Never Ends MULTITHREADING 958 Example: A Nonresponsive GUI 959 CHAPTER 19 Java Never Ends 19.1 MULTITHREADING 958 Example: A Nonresponsive GUI 959 Thread.sleep 959 The getgraphics Method 963 Fixing a Nonresponsive Program Using Threads 964 Example: A Multithreaded

More information

JFrame & JLabel. By Iqtidar Ali

JFrame & JLabel. By Iqtidar Ali JFrame & JLabel By Iqtidar Ali JFrame & its Features JFrame is a window with border, title and buttons. The component added to frame are referred to as its contents & are managed by the content pane. To

More information

Unit 5 - Exception Handling & Multithreaded

Unit 5 - Exception Handling & Multithreaded Exceptions Handling An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/application

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Multimedia Programming

Multimedia Programming Multimedia Programming Medialogy, 8 th Semester, Aalborg University Wednesday 6 June 2012, 09.00 12.00 Instructions and notes You have 3 hours to complete this examination. Neither written material nor

More information

2018/2/5 话费券企业客户接入文档 语雀

2018/2/5 话费券企业客户接入文档 语雀 1 2 2 1 2 1 1 138999999999 2 1 2 https:lark.alipay.com/kaidi.hwf/hsz6gg/ppesyh#2.4-%e4%bc%81%e4%b8%9a%e5%ae%a2%e6%88%b7%e6%8e%a5%e6%94%b6%e5%85%85%e5 1/8 2 1 3 static IAcsClient client = null; public static

More information

CSCI 201L Midterm Written Summer % of course grade

CSCI 201L Midterm Written Summer % of course grade CSCI 201L Summer 2016 10% of course grade 1. Abstract Classes and Interfaces Give two differences between an interface and an abstract class in which all of the methods are abstract. (0.5% + 0.5%) 2. Serialization

More information

Author - Ashfaque Ahmed

Author - Ashfaque Ahmed Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-1983801570) published by Create Space Independent Publishing Platform, USA Author - Ashfaque Ahmed Technical support

More information

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver Building a GUI in Java with Swing CITS1001 extension notes Rachel Cardell-Oliver Lecture Outline 1. Swing components 2. Building a GUI 3. Animating the GUI 2 Swing A collection of classes of GUI components

More information

The Islamic University Gaza Department of Electrical & Computer Engineering. Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324

The Islamic University Gaza Department of Electrical & Computer Engineering. Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324 The Islamic University Gaza Department of Electrical & Computer Engineering Midterm Exam Spring 2012 Computer Programming II (Java) ECOM 2324 Instructor: Dipl.-Ing. Abdelnasser Abdelhadi Date: 31.03.2013

More information

Written by: Dave Matuszek

Written by: Dave Matuszek RMI Remote Method Invocation Written by: Dave Matuszek appeared originally at: http://www.cis.upenn.edu/~matuszek/cit597-2003/ 28-May-07 The network is the computer * Consider the following program organization:

More information