Class/220801
Class 예제(1_MemberDAO)
by pms93
2022. 8. 1.
package quiz4;
import java.util.ArrayList;
public class MemberDAOImpl implements IMemberDAO{
private ArrayList<MemberDTO> members = new ArrayList<>();
@Override
public void insert(MemberDTO member) {
members.add(member);
}
@Override
public int getIdx(String email) {
int index = -1;
for(MemberDTO m : members) {
if(m.getEmail().equals(email)) {
index = members.indexOf(m);
break;
}
}
return index;
}
@Override
public MemberDTO selectEmail(int index) {
return members.get(index);
}
@Override
public void delete(int index) {
members.remove(index);
}
@Override
public ArrayList<MemberDTO> selectAll() {
return members;
}
@Override
public void update(int index, String name, String mobile) {
MemberDTO member = members.get(index);
member.setName(name);
member.setMobile(mobile);
members.set(index, member);
}
}