본문 바로가기
중간평가/disassemble_1

중간평가 (DTO, DAO)

by pms93 2022. 8. 10.

<< MemberDTO Interface >>

package disassemble.DTO;

public interface IMemberDTO {
	public void setEmail(String email);
	public void setPassword(String password);
	public void setName(String name);
	public void setRegisterDate(String registerDate);

	public String getEmail();
	public String getPassword();
	public String getName();
	public String getRegisterDate();
}

 

<< MemberDTO >>

package disassemble.DTO;

public class MemberDTO implements IMemberDTO{

	private String email, password, name, registerDate;
	
	@Override
	public void setEmail(String email) {
		this.email = email;
		
	}

	@Override
	public void setPassword(String password) {
		this.password = password;
		
	}

	@Override
	public void setName(String name) {
		this.name = name;
		
	}

	@Override
	public void setRegisterDate(String registerDate) {
		this.registerDate = registerDate;
		
	}

	@Override
	public String getEmail() {
		return this.email;
	}

	@Override
	public String getPassword() {
		return this.password;
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public String getRegisterDate() {
		return this.registerDate;
	}

}

 

<< RegisterRequest Interface >>

package disassemble.DTO;

public interface IRegisterRequest {
	public String getEmail();
	public String getName() ;
	public String getPassword();
	public String getConfirmPassword();
	
	public void setPassword(String password);
	public void setEmail(String email);
	public void setName(String name);
	public void setConfirmPassword(String confirmPassword);
}

 

<< RegisterRequest >>

package disassemble.DTO;

public class RegisterRequest implements IRegisterRequest{

	private String email, name, password, confirmPassword;
	
	@Override
	public String getEmail() {
		return this.email;
	}

	@Override
	public String getName() {
		return this.name;
	}

	@Override
	public String getPassword() {
		return this.password;
	}

	@Override
	public String getConfirmPassword() {
		return this.confirmPassword;
	}

	@Override
	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public void setEmail(String email) {
		this.email = email;
		
	}

	@Override
	public void setName(String name) {
		this.name = name;
		
	}

	@Override
	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
		
	}

}

 

<< MemberDAO Interface >>

package disassemble.DAO;

import java.util.Collection;
import disassemble.DTO.*;


public interface IMemberDAO {
	public Collection<MemberDTO> selectAll() ;
	public MemberDTO selectEmail(String email);
	public void insert(MemberDTO member);
	public void update(MemberDTO member);
	public void delete(String email);
}

 

<< MemberDAO >>

package disassemble.DAO;

import java.util.Collection;
import java.util.HashMap;

import disassemble.DTO.*;

public class MemberDAO implements IMemberDAO {
	
	HashMap<String, MemberDTO> members = new HashMap<>();
	
	@Override
	public void insert(MemberDTO member) {
		members.put(member.getEmail(), member);
	}
	
	@Override
	public Collection<MemberDTO> selectAll() {
		return members.values();
	}

	@Override
	public MemberDTO selectEmail(String email) {
		return members.get(email);
	}


	@Override
	public void update(MemberDTO member) {
		members.replace(member.getEmail(), member);
		
	}

	@Override
	public void delete(String email) {
		members.remove(email);
	}


}

'중간평가 > disassemble_1' 카테고리의 다른 글

중간평가 (Service)  (0) 2022.08.10
중간평가 (Main)  (0) 2022.08.10