//used by threads, instantiates a new ATM object public void threadBegin() { ATMForms form = new ATMForms(); ATM atm = new ATM(ac, form, 1); }
// the atm constructor takes an array of account objects as a referance public ATM(Account[] ac, ATMForms frm, int no) { this.ac = ac; this.form = frm; this.numpad = new Button[3, 4]; //set attributes, settings of UI objects dial.Location = new Point(200, 150); //*no+50, 150); next.Location = new Point(300, 150); //*no+50, 150); dial.ForeColor = Color.White; dial.ReadOnly = true; dial.BackColor = Color.Black; display.ReadOnly = true; display.BackColor = Color.Black; display.ForeColor = Color.LightGreen; //The following button is clicked to make the current account wait for another user to access //and withdraw from the same account syncThreads.Location = new Point(100, 300); this.syncThreads.Text = "Make thread withdraw simultaneously"; syncThreads.Click += new EventHandler(syncClicked); syncThreads.AutoSize = true; syncThreads.ForeColor = Color.DarkRed; form.Controls.Add(syncThreads); //set up next button next.Text = "NEXT"; next.Click += new EventHandler(nextclicked); next.Show(); //add items to form form.Controls.Add(next); form.Controls.Add(dial); dial.Show(); writer("hello from ATM"); display.Multiline = true; Font dis = new Font("Calibri", 12.0f); display.Location = new Point(200, 50); display.Font = dis; display.Size = new Size(400, 50); form.Controls.Add(display); display.Show(); // set up numpad buttons for (int i = 0; i < 3; i++) { // count = 1; for (int t = 0; t < 4; t++) { int startpos = 100 * no; numpad[i, t] = new Button(); numpad[i, t].Click += new EventHandler(readnum); //numpad[i,t].Text = Convert.ToString(count); numpad[i, t].Location = new Point(200 + (i * 50), 200 + (20 * t)); form.Controls.Add(numpad[i, t]); numpad[i, t].Show(); } } //labelling numpad buttons for (int i = 0; i < 3; i++) { numpad[i, 0].Text = Convert.ToString(i + 1); } for (int i = 0; i < 3; i++) { numpad[i, 1].Text = Convert.ToString(4 + i); } for (int i = 0; i < 3; i++) { numpad[i, 2].Text = Convert.ToString(7 + i); } numpad[1, 3].Text = "0"; numpad[0, 3].Text = "CLEAR"; //ask for account number and store result in acctiveAccount (null if no match found) display.Text = "Enter your account number..."; nxte = "Account"; //hide tha baility to synce accounts while there is no active account syncThreads.Hide(); frm.ShowDialog(); }