Gym2/src/gym/Trainer.java
/*
     * This function return boolean.
     * True if id of new trainer is exist.
     * False if all data are valied.
     */
This function return boolean.
True if id of new trainer is exist.
False if all data are valied.
This function return boolean . True if id of new trainer is exist . False if all data are valied .
public boolean add(ArrayList<Trainer>trainers,Trainer newTrainer)
    {
        ArrayList<Person> t = new ArrayList<>();
        for (int i = 0; i < trainers.size(); i++) {
           t.add(trainers.get(i));
        }
        boolean flage = false;
        for (int i = 0; i < t.size(); i++) {
            if (t.get(i).getId()==newTrainer.getId()) {
                 flage=true;
                 break;
            }
        }
        if (flage) {
            return true;
        }else{
            this.add(t, newTrainer);
            trainers.clear();
            for (int j = 0; j < t.size(); j++) {
                trainers.add((Trainer)t.get(j));
            } 
            return false;
        }
    }
public boolean add ( ArrayList < Trainer > trainers , Trainer newTrainer ) { ArrayList < Person > t = new ArrayList < > ( ) ; for ( int i = 0 ; i < trainers . size ( ) ; i ++ ) { t . add ( trainers . get ( i ) ) ; } boolean flage = false ; for ( int i = 0 ; i < t . size ( ) ; i ++ ) { if ( t . get ( i ) . getId ( ) == newTrainer . getId ( ) ) { flage = true ; break ; } } if ( flage ) { return true ; } else { this . add ( t , newTrainer ) ; trainers . clear ( ) ; for ( int j = 0 ; j < t . size ( ) ; j ++ ) { trainers . add ( ( Trainer ) t . get ( j ) ) ; } return false ; } }
This function return boolean.
This function return boolean .