Gym2/src/gym/Class.java
/*
     * This function return boolean.
     * True if choosen tariner has another class in chosen day and time.
     * False if all data are valied.
     */
This function return boolean.
True if choosen tariner has another class in chosen day and time.
False if all data are valied.
This function return boolean . True if choosen tariner has another class in chosen day and time . False if all data are valied .
public boolean edit (ArrayList<Class> classes, Class updateClasse, ArrayList<Trainer> trainers)
    {
        boolean flage = false;
        int position = 0;
        for (int i = 0; i < trainers.size(); i++) {
            if (trainers.get(i).getId()== trainer_id) {
                position = i;
                break;
            }
        }
        ArrayList<Dates> d = new ArrayList<Dates>();
        d = trainers.get(position).getDates();
        for (int j = 0; j < d.size(); j++) {
            if (d.get(j).day.equals(day) && d.get(j).time == time) {
               flage = true; 
            }
        }
        if (flage == true) {
            return true;
        }
        else{
            int index = -1;
            for (int i = 0; i < classes.size(); i++) {
                if (classes.get(i).getClass_id() == class_id) {
                    index=i;
                }
            } 
            classes.set(index, updateClasse); 
            return false;
        }
    }
public boolean edit ( ArrayList < Class > classes , Class updateClasse , ArrayList < Trainer > trainers ) { boolean flage = false ; int position = 0 ; for ( int i = 0 ; i < trainers . size ( ) ; i ++ ) { if ( trainers . get ( i ) . getId ( ) == trainer_id ) { position = i ; break ; } } ArrayList < Dates > d = new ArrayList < Dates > ( ) ; d = trainers . get ( position ) . getDates ( ) ; for ( int j = 0 ; j < d . size ( ) ; j ++ ) { if ( d . get ( j ) . day . equals ( day ) && d . get ( j ) . time == time ) { flage = true ; } } if ( flage == true ) { return true ; } else { int index = - 1 ; for ( int i = 0 ; i < classes . size ( ) ; i ++ ) { if ( classes . get ( i ) . getClass_id ( ) == class_id ) { index = i ; } } classes . set ( index , updateClasse ) ; return false ; } }
This function return boolean.
This function return boolean .
//Start check if trainer has class in chossen day and time. //End check if trainer has class in chossen day and time. // Get the index of class to be able to make updta on it. // Reblace old data with updated data.