Results 1 to 3 of 3
  1. #1
    stut is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Searching bank account with 3 files in package

    Java Code:
    package Acconting;
    public class BankAccount {
    	//Fields
    	private Integer number;
    	private String name;
    	private double balance;
    	private double amount;
    	private boolean overdraft;
    	private double interest_rate;
       
    	//Constructors
    	public BankAccount(Integer number,String name,double balance,double maximumsum,double depositsum,double creditsum,boolean overdraft){
    		this.number=number;
    		this.name=name;
    		this.balance=balance;
    		this.amount=amount;
          this.interest_rate=interest_rate;
    	}
    	public BankAccount(float initialbalance){
    		this.balance=initialbalance;
    	}
    	
             //Methods
    	 public Integer getnumber() {
    		return number;
    	}
       
       public void setNumber(Integer number) {
    		this.number=number;
    	}
    	
    	public String getName() {
    		return name;
    	}
    
            public void setName(String name) {
    		this.name=name;
    	}
    
            public void getBalance(double balance) {
    		this.balance=balance;
    	}
    
    	public Boolean hasOverdraft() {if(overdraft);
    		return true;
    	}
    
    	public boolean clearCheck(double amount) {
    		if (amount<balance||hasOverdraft()==true);
          return true;
          }
          
       public void deposit(double a){
       this.balance+=a;
       }
       
        public void withdraw(double b){
       this.balance-=b;
       }
       
       public void deposit(String str){
       this.balance+=Double.parseDouble(str);
       }
       
       public void setAmount(double ammount) {
    		this.amount=amount;
    	}
    
       
       public void setInitial_rate(double interest_rate) {
    		this.interest_rate=interest_rate;
    	}
       
       public double getRate () {
       return interest_rate;
       }
       
       public void addIntestrate (double interest_rate){
       this.balance=balance*interest_rate+balance;
    }
    }
    
    
    
    @@@
    package Acconting;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class Parser {
    	BankAccount[] accounts;
    	Parser(BankAccount[] accounts){
    		this.accounts=accounts;
    	}
    	//Full descriprtion of Account
    	public void opys(BankAccount BankAccount){
    		System.out.println("////////////////");
    		System.out.println("Number:"+BankAccount.getNumber());
    		System.out.println("Name:"+BankAccount.getName());
    		System.out.println("Overdraft:"+BankAccount.hasOverdraft());
    		System.out.println("Balance:"+BankAccount.getBalance());
    		System.out.println("Rate:"+BankAccount.getRate());
    	}
        
    	//First search method for string
    	public BankAccount[] searchParametr(String parametr, String value){
    		List<BankAccount>listOfBankAccount=new ArrayList<BankAccount>();
    		if(parametr.equals("Name")){
    			for(int i=0;i<accounts.length;i++){
    				if(accounts[i].getName().equals(value)){
    					listOfBankAccount.add(accounts[i]);
    				}
    			}
    		}
    		return listOfBankAccount.toArray(new BankAccount[listOfBankAccount.size()]);
    	}
    	// search method for boolean
    	public BankAccount[] searchParametr(String parametr, Boolean value){
    		List<BankAccount>listOfBankAccount=new ArrayList<BankAccount>();
    		if(parametr.equals("Overdraft")){
    			for(int i=0;i<accounts.length;i++){
    				if(accounts[i].hasOverdraft().equals(value)){
    					listOfBankAccount.add(accounts[i]);
    				}
    			}
    		}
    		return listOfBankAccount.toArray(new BankAccount[listOfBankAccount.size()]);
    	}
      	//First search method for numbers
    	public BankAccount[] searchParametr(String parametr, Integer value){
    		List<BankAccount>listOfBankAccount=new ArrayList<BankAccount>();
    		if(parametr.equals("Number")){
    			for(int i=0;i<accounts.length;i++){
    				if(accounts[i].getNumber().equals(value)){
    					listOfBankAccount.add(accounts[i]);
    				}
    			}
    		}
    		if(parametr.equals("Balance")){
    			for(int i=0;i<accounts.length;i++){
    				if(accounts[i].getBalance()!=0 && accounts[i].getBalance()<value){
    					listOfBankAccount.add(accounts[i]);
    				}
    			}
    		}
    		return listOfBankAccount.toArray(new BankAccount[listOfBankAccount.size()]);
    	}
    }
    
    
    @@@package Acconting;
    
    public class Manipulation {
    
    	public static void main(String[] args) {
    		//Accounts array
    		BankAccount accounts[]={new BankAccount(100, "Main", 100.00,0.00,true,0.00),
    			new BankAccount(101, "Auxillary" , 10.00, 5.00,true,0.15),
    			new BankAccount(102, "Deposit" , 20.0, 10.0,false,0.1),
    			new BankAccount(103, "Credit1" , 10.0, 10.0,true,0.2),
    			new BankAccount(104, "Credit2" , 40.0, 10.0,true,0.25),
    			new BankAccount(105, "Credit3" , 10.0,5.0,true,0.15),
             new BankAccount(12.00)};
          //parser object
    		Parser parserobject=new Parser(accounts);
    		//Вивід депозитного рахунку на екран за допомогою парсера 
    		System.out.print("--------------------- До змін");
    		parserobject.opys(accounts[2]);
    		
          //Editing with accounts methods
    		accounts[2].deposit(10);
    		accounts[2].setName("Deposit1");
          accounts[2].addInterestrate(0.1);
    		//Вивід відредагованого рахунку на екран за допомогоюкласу парсера 
    		System.out.print("---------------------Після змін");
    	   parserobject.opys(accounts[2]);
          
    		//Depsoit search
    		BankAccount searchedName[]=parserobject.searchParametr("Name", "Deposit");
    		//Вивід даних за пошуком
    		System.out.print("---------------------після пошуку депозитів");
    		for(BankAccount b:searchedName){
    			parserobject.opys(b);
    		}
          
    		//Overdradt search
    		BankAccount searchedOverdraft[]=parserobject.searchParametr("Overdraft", true);
    		//Вивід даних за пошуком
    		System.out.print("--------------------outputting after Searching by elevator");
    		for(BankAccount b:searchedOverdraft){
    			parserobject.opys(b);
    		}
          
    		//Acounts less than 40
    		BankAccount searchedBalance[]=parserobject.searchParametr("Balance", 40);
    		//Вивід даних за пошуком
    		System.out.print("--------------------outputting after Searching by Square");
    		for(BankAccount b:searchedBalance){
    			parserobject.opys(b);
    		}		
    }
    }
    Last edited by JosAH; 06-05-2013 at 10:12 PM. Reason: added [code] ... [/code] tags

  2. #2
    stut is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Re: Searching bank account with 3 files in package

    In 3 file it is possible to view the results of displaying and after editing. but the search by criterion is imposible. What to changwe or correct?

  3. #3
    stut is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Re: Searching bank account with 3 files in package

    Would anybody show where are errors in this code. In a parser class (2), or in a loop (3). Why it could be search. May be there are alternative ways of searching in the array?

Similar Threads

  1. basic bank account
    By captain_turkiye in forum New To Java
    Replies: 5
    Last Post: 10-16-2011, 06:15 PM
  2. Adding Interest to a Bank Account
    By petur170 in forum New To Java
    Replies: 20
    Last Post: 05-26-2011, 03:28 AM
  3. Bank Account Project
    By Haal in forum New To Java
    Replies: 0
    Last Post: 03-20-2011, 08:30 PM
  4. java bank account problem
    By awil121 in forum New To Java
    Replies: 1
    Last Post: 10-13-2010, 11:47 PM
  5. Bank Account
    By HPcompaq256 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 10:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •