1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | package com.hanbit.oop.serviceImpl; import com.hanbit.oop.domain.MemberBean; import com.hanbit.oop.service.AdminService; public class AdminServiceImpl implements AdminService{ int count; MemberBean member; MemberBean[] list; public AdminServiceImpl(int limit){ count=0; member=new MemberBean(); list=new MemberBean[limit]; } @Override public void addMember(MemberBean member) { list[count]=member; for(int i=0;i<(count+1);i++){ System.out.println(list[i].toString()); } count++; } @Override public MemberBean[] getMembers() { return list; } @Override public int countMembers() { return count; } @Override public MemberBean findById(String id) { member=new MemberBean(); for(int i=0;i<list.length;i++){ if(id.equals(list[i].getId())){ member=list[i]; } } return member; } @Override public void updatePass(MemberBean member) { // TODO Auto-generated method stub } @Override public MemberBean[] findByName(String name) { int x=0; for(int i=0;i<list.length;i++){ if(name.equals(list[i].getName())){ x++; } } MemberBean[] members=new MemberBean[x]; int j=0; for(int i=0;i<list.length;i++){ if(name.equals(list[i].getName())){ members[j]=list[i]; j++; } if(x==j){ break; } } return members; } } | cs |
'Java' 카테고리의 다른 글
[자바 알고리즘] 팩토리얼 Factorial.java (0) | 2020.04.30 |
---|---|
[자바 8] 람다 Lambda 5 가지 종류 (0) | 2020.04.30 |
[자바 Swing] Calculator.java (0) | 2020.04.30 |
19. 회원관리 Swing 앱 :: AdminController.java (0) | 2020.04.30 |
19. 회원관리 Swing 앱 :: EmployeeUI.java (0) | 2020.04.30 |