Gym2/src/gym/Member.java
/*
     * This function return integer.
     * 1 if id of new member is exist.
     * 2 if chosen class has limited number of members (limited number of members seted manula as 11).
     * 3 if all data are valied.
     */
This function return integer.
1 if id of new member is exist.
2 if chosen class has limited number of members (limited number of members seted manula as 11).
3 if all data are valied.
This function return integer . 1 if id of new member is exist . 2 if chosen class has limited number of members ( limited number of members seted manula as 11 ) . 3 if all data are valied .
public int add(ArrayList<Member> members, Member newMember, ArrayList<Class> Classes) {
        ArrayList<Person> m = new ArrayList<>();
        for (int i = 0; i < members.size(); i++) {
           m.add(members.get(i));
        }
        boolean flage = false;
        for (int i = 0; i < m.size(); i++) {
            if (m.get(i).getId()==newMember.getId()) {
                flage=true;
                break;
            }
        }
        if (flage) {
          return 1;  
        }else{
            int num_of_members = 0; 
            int i;
            for (i = 0; i < Classes.size(); i++) {
                if(newMember.getClass_id() == Classes.get(i).getClass_id())
                {
                num_of_members = Classes.get(i).getNum_of_members();
                break;
                } 
            }
            if(num_of_members < 11)
            {
                this.add(m, newMember);
                members.clear();
                for (int j = 0; j < m.size(); j++) {
                   members.add((Member)m.get(j));
                }
                Classes.get(i).increment_num_of_members(); 
                return 2;
            }
            else{
            return 3;
            }
        } 
    }
public int add ( ArrayList < Member > members , Member newMember , ArrayList < Class > Classes ) { ArrayList < Person > m = new ArrayList < > ( ) ; for ( int i = 0 ; i < members . size ( ) ; i ++ ) { m . add ( members . get ( i ) ) ; } boolean flage = false ; for ( int i = 0 ; i < m . size ( ) ; i ++ ) { if ( m . get ( i ) . getId ( ) == newMember . getId ( ) ) { flage = true ; break ; } } if ( flage ) { return 1 ; } else { int num_of_members = 0 ; int i ; for ( i = 0 ; i < Classes . size ( ) ; i ++ ) { if ( newMember . getClass_id ( ) == Classes . get ( i ) . getClass_id ( ) ) { num_of_members = Classes . get ( i ) . getNum_of_members ( ) ; break ; } } if ( num_of_members < 11 ) { this . add ( m , newMember ) ; members . clear ( ) ; for ( int j = 0 ; j < m . size ( ) ; j ++ ) { members . add ( ( Member ) m . get ( j ) ) ; } Classes . get ( i ) . increment_num_of_members ( ) ; return 2 ; } else { return 3 ; } } }
This function return integer.
This function return integer .
//Add new member to data. // Increment number of member of class that user join it.