Gym2/src/gym/Class.java
/*
     * This function return integer.
     * 1 if id of new class is exist.
     * 2 if choosen tariner has another class in chosen day and time.
     * 3 if all data are valied.
     */
This function return integer.
1 if id of new class is exist.
2 if choosen tariner has another class in chosen day and time.
3 if all data are valied.
This function return integer . 1 if id of new class is exist . 2 if choosen tariner has another class in chosen day and time . 3 if all data are valied .
public int add (ArrayList<Class> classes, Class newClasse, ArrayList<Trainer> trainers)      
    {
        boolean flage0 = false;
        for (int i = 0; i < classes.size(); i++) {
            if (classes.get(i).getClass_id() == class_id) {
                flage0 = true;
                break;
            }
        }
        if(flage0 == true)
        {
        return 1;
        }
        else{
            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 2;
            }
            else
            {
                trainers.get(position).dates.add(new Dates(day,time));
                classes.add(newClasse); 
                return 3;
            }
        }
    }
public int add ( ArrayList < Class > classes , Class newClasse , ArrayList < Trainer > trainers ) { boolean flage0 = false ; for ( int i = 0 ; i < classes . size ( ) ; i ++ ) { if ( classes . get ( i ) . getClass_id ( ) == class_id ) { flage0 = true ; break ; } } if ( flage0 == true ) { return 1 ; } else { 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 2 ; } else { trainers . get ( position ) . dates . add ( new Dates ( day , time ) ) ; classes . add ( newClasse ) ; return 3 ; } } }
This function return integer.
This function return integer .
//Start check if trainer has class in chosen day and time. //End check if trainer has class in chosen day and time. //add day and time to trainer data. //Add new class to data.