Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

validation

  Asked By: Mali    Date: Oct 04    Category: Java    Views: 481
  

i have some code that i have got that is for an assignment
one question that i have to write is that only valid data is to be
added to an object.
these are the things that have to have validation

*the clients ID number and surname cant be blank
* clients age must be a numeric value within an acceptable range like
say not > 150

* every client and account must have a unique ID number


here is the code that i have got for this


*********************************************************************
* if new client button is clicked then *
* create new client object *
* read data from text fields and set the client object's values *
* add this client object to array of client objects *
*********************************************************************/
if (obj == btnAddData) {

//this if for when user enters a transaction amount

if (txtTranxAmount.getText().equals("")){
double TrnAmt = Double.parseDouble(txtTranxAmount.getText());


if (accountType.getSelectedCheckbox().getLabel().equals("Cheque")) {
Cheq.setBalance(Cheq.getBalance() + TrnAmt )

} else{

if (accountType.getSelectedCheckbox().getLabel().equals("EFTCard")) {
Eft.setBalance(Cheq.getBalance() + TrnAmt )

}//end of the if it was eftcard


if ((Cheq == null) && (Eft == null ))

System.out.println("NO AMOUNT WAS ENTERED FOR A TRANSACTION");
// no AMOUNT WAS ENTERED FOR A TRANSACTION





//this if statement is here so is a user wants to create a an account
they must enter a clientno
if (! txtClientNo.getText().equals("")) {



Clt = new Client(txtClientNo.getText(), txtFirstname.getText(),
txtSurname.getText(), txtClientAge.getText());


if (accountType.getSelectedCheckbox().getLabel().equals("Cheque")) {

double InterestRate = Double.parseDouble(txtInterestRate.getText());
double AccountBalance = Double.parseDouble(txtAccountBalance.getText
());

Acc = new Cheque(promptAccType.getText(),txtAccountNo.getText(),
AccountBalance, InterestRate);

} else {


if (accountType.getSelectedCheckbox().getLabel().equals("EFTcard")) {

double InterestRate = Double.parseDouble(txtInterestRate.getText());
double AccountBalance = Double.parseDouble(txtAccountBalance.getText
());

Acc = new EFTCard(promptAccType.getText(),txtAccountNo.getText(),
AccountBalance, InterestRate);


} // THIS closes the if statement of the if equals bit

Brh = new Branch (branchArray[availableBranches.getSelectedIndex
()].getBranchName(),
branchArray[availableBranches.getSelectedIndex()].getBranchCode());

}

} else {

System.out.println("PLEASE ENTER A CLIENT NUMBER");
// no client number

}


} // end of if for btnAddData

um seeing that this is the interface code side and i have other class
would i need to add it in the class or in the interface code which
would be beta, please could someone suggest how

Share: 

 

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

 
Didn't find what you were looking for? Find more on validation Or get search suggestion and latest updates.




Tagged: