Gym2/src/gym/Member.java
/* This function return boolean.
     * True if in user chosed class has limited number of members (limited number of members seted manula as 11).
     * False in all data are valied.
     */
This function return boolean.
True if in user chosed class has limited number of members (limited number of members seted manula as 11).
False in all data are valied.
This function return boolean . True if in user chosed class has limited number of members ( limited number of members seted manula as 11 ) . False in all data are valied .
public boolean edit(ArrayList<Member> members, Member member, ArrayList<Class> Classes) {
        ArrayList<Person> m = new ArrayList<>();
        for (int i = 0; i < members.size(); i++) {
           m.add(members.get(i));
        }
        int num_of_members = 0;
        for (int i = 0; i < Classes.size(); i++) {
            if(member.getClass_id() == Classes.get(i).getClass_id())
            {
            num_of_members = Classes.get(i).getNum_of_members();
            break;
            } 
        }
         int index = -1;
         for (int i = 0; i < members.size(); i++) {
             if (members.get(i).getId()==member.getId()) {
                 index=i;
                 break;
             }
        }
        if(num_of_members < 11 || class_id == members.get(index).getClass_id())
        {
            for (int i = 0; i < Classes.size(); i++) {
                if (Classes.get(i).getClass_id() == members.get(index).getClass_id()) {
                    Classes.get(i).decrement_num_of_members();
                    break;
                }
            }
            for (int i = 0; i < Classes.size(); i++) {
                 if (Classes.get(i).getClass_id() == class_id) {
                    Classes.get(i).increment_num_of_members();
                    break;
                }
            }
            this.edit(m, index, member);
            for (int i = 0; i < members.size(); i++) {
               members.set(i, (Member)m.get(i));
            }
            return true;
        }
        else{
            return false;
        }
    }
public boolean edit ( ArrayList < Member > members , Member member , ArrayList < Class > Classes ) { ArrayList < Person > m = new ArrayList < > ( ) ; for ( int i = 0 ; i < members . size ( ) ; i ++ ) { m . add ( members . get ( i ) ) ; } int num_of_members = 0 ; for ( int i = 0 ; i < Classes . size ( ) ; i ++ ) { if ( member . getClass_id ( ) == Classes . get ( i ) . getClass_id ( ) ) { num_of_members = Classes . get ( i ) . getNum_of_members ( ) ; break ; } } int index = - 1 ; for ( int i = 0 ; i < members . size ( ) ; i ++ ) { if ( members . get ( i ) . getId ( ) == member . getId ( ) ) { index = i ; break ; } } if ( num_of_members < 11 || class_id == members . get ( index ) . getClass_id ( ) ) { for ( int i = 0 ; i < Classes . size ( ) ; i ++ ) { if ( Classes . get ( i ) . getClass_id ( ) == members . get ( index ) . getClass_id ( ) ) { Classes . get ( i ) . decrement_num_of_members ( ) ; break ; } } for ( int i = 0 ; i < Classes . size ( ) ; i ++ ) { if ( Classes . get ( i ) . getClass_id ( ) == class_id ) { Classes . get ( i ) . increment_num_of_members ( ) ; break ; } } this . edit ( m , index , member ) ; for ( int i = 0 ; i < members . size ( ) ; i ++ ) { members . set ( i , ( Member ) m . get ( i ) ) ; } return true ; } else { return false ; } }
This function return boolean.
This function return boolean .
// Get the index of member to be able to make updta on it. // Decrement number of member of class that user leave it. // Increment number of member of class that user join it. // Reblace old data with updated data.