Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Scanner scanner = new Scanner(System.in);
- public static Bank newBank = new Bank("BMCE");
- public static void addNewCostumer(){
- System.out.println("Choose a branch :");
- String branchChoosed = scanner.nextLine();
- Branches branches = newBank.queryBranch(branchChoosed);
- if(branches == null){
- System.out.println("There are a problem, or you are entered a wrong name of branch");
- }
- else{
- System.out.println("Enter the name costumer :");
- String nameOfCostumer = scanner.nextLine();
- System.out.println("Enter the transaction number :");
- double transactions = scanner.nextDouble();
- scanner.nextLine();
- if(newBank.addNewCostumer(branches,nameOfCostumer,transactions)){
- System.out.println("The costumer was created in branch name :"+branches.getNameOfBranch());
- }else{
- System.out.println("Sorry you dindn't create a costumer in "+branches.getNameOfBranch()+" Try again please :)");
- }
- }
- private String name;
- private ArrayList<Branches> branchesArrayList = new ArrayList<>();
- public boolean addNewCostumer(Branches nameOfExistingBranch,String nameOfNewCostumer,double newTransaction){
- int position = findBranch(nameOfExistingBranch);
- if(position<0){
- System.out.println("There is not branch with this name");
- return false;
- }
- else{
- if(this.branchesArrayList.get(position).findCostumer(nameOfNewCostumer)>=0){
- System.out.println("You have already an existing costumer with that name");
- return false;
- }
- else{
- this.branchesArrayList.get(position).addNewCostumer(nameOfNewCostumer,newTransaction);
- return true;
- }
- }
- }
- public int findBranch(Branches branches){
- int position = this.branchesArrayList.indexOf(branches);
- if(position>=0){
- return position;
- }
- else
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement