Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Help with searching and deleting arrays

  Asked By: Jasmine    Date: Jun 06    Category: Java    Views: 888
  

this assignment is for school and we arent required to use SQL
code only java.i have a problem i have created a array called
ClntArray that holds the arrays, i have some methods that find the
client also searching them too. but i have trouble writing the code
in the interface tht will access them when a btnSearch, btnDelete,
btnnextClient, btnPrevious, so here is the code that i have in the
interface also the ClntArray please put ur suggestions in as i am
stuk at this point in time

import java.awt.*;
import java.applet.*;
import java.awt.event.*;



public class Assignment2 extends Applet
implements ActionListener {


private Branch Brh = new Branch ();
private Client Clt = new Client ();
private Account Acc = new Account ();
private Cheque Cheq = new Cheque ();
private EFTCard Eft = new EFTCard();
private ClntArray ctArray = new ClntArray ();


// create an array to hold upto ten branch objects
private Branch branchArray[] = new Branch[10];


// declare and initialise variable to keep count of
// howmany branches
private int branchCount = 0;
// Declare variables for each type of component required for this
applet



// Buttons for client processing
Button btnNewClient, btnUpdateClient, btnDeleteClient;
Button btnSearchClient, btnNextClient, btnPreviousClient;

// Buttons for account and transaction processing
Button btnNewAccount, btnUpdateAccount, btnDeleteAccount;
Button btnSearchAccount, btnNextAccount, btnPreviousAccount;
Button btnNewTranx, btnPrintStatement;

// Buttons for misc processing
Button btnClear;

// declare variables for checkboxes and a checkbox group
Checkbox chequeAccount, EFTAccount;
CheckboxGroup accountType;

// choice list to hold branches that can be selected from
Choice availableBranches;

// labels and textfields for client processing
Label clientHeading;
Label promptSName, promptFName, promptClientPh,
promptClientAge,promptClientNo;
TextField txtSurname, txtFirstname, txtClientPh, txtClientAge,
txtClientNo;

// labels and textfields for account processing
Label accountHeading, accountTip;
Label promptAccNo, promptAccBalance, promptAccInterest,
promptAccType;
TextField txtAccountNo, txtAccountBalance, txtInterestRate,
txtTranxAmount;
Label promptTranxAmount, promptSelectBranch;

// general labels and text fields
Label header, footer;
TextArea results;

// panels for client processing
Panel pTextFields, pClientButtons, pClientStuff;

// account processing panels
Panel pAccountFields, pAccountButtons, pAccountStuff;

// miscelaneous panels used for formatting user interface
Panel pTop, pCentre, pBottom, pAllTextFields;
Panel pCheckBoxes, pBranches, pLists;

// variable used to create output string
String msg = "";


/***** init() method
*************************************************
* This method will create all required objects, add them to
the *
* applet, and register interest in events on some objects
through *
* listener
classes *

**********************************************************************
*/
//the array of clients beta off putn it herer ten trying
// to insert it in the client class


public class ClntArray {
Client ctArray[] = new Client[50];
int ct_count = 0;
Client newct = new Client();

// this will + a client
public void AddClient(Client newclient) {

ctArray[ct_count] = newclient;
ct_count++;
}



// this is to find position client
public int findLoc(String ctNo) {
for (int x = 0; x < ct_count; x++) {
if (ctNo.compareTo(ctArray[x].getClientNo()) == 0)
return x;
}

return -1 ;
//mean that if the for bit doesnt find something then
//in interface itll say if - 1 'i think'
}



// method to return client details

public Client getClient(int x) {
return ctArray[x];
}

// in here i must put a method that will aloow me to delete the client
//look at the webct to get an idea

// this is to find position client n then delete the object array
public int remove(String ctNo) {

for (int x = findLoc(ctNo); x < ct_count -1 ; x++) {

ctArray[x] = ctArray[x + 1];

}
ctArray[ ct_count - 1] = null;

ct_count--;
}



} //end of class

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Help with searching and deleting arrays Or get search suggestion and latest updates.




Tagged: