코린이 3

2022.03.16 Interpace 활용 <3단 구현> 코드로 보기

Interface Auth public interface Auth { //권한 void execute(); } UI AbstractUI // abstract = 추상클래스 // implement는 interface 상속 //추상클래스를 interface로 한번더 빼준다 (interface가 더 유연하니까) public abstract class AbstractUI implements Auth { private Scanner scanner; public void print(String msg){ System.out.println(msg); } public int inputInt(String msg){ System.out.println(msg); return Integer.parseInt(scanner.ne..

ArrayList

기존배열 private VoterVO [] arr; public VoterDAO(){ arr= new VoterVO [4]; arr[0] = new VoterVO(1, "홍길동"); arr[1] = new VoterVO(2, "고길동"); arr[2] = new VoterVO(3, "박길동"); arr[3] = new VoterVO(4, "이길동"); } 기존 배열 방식 각 배열에 내용을 지정해주어야 하고 처음 설정했던 크기만큼만 사용할 수 있음 ArrayList 길이의 제한이없다 int의 크기만큼 만들어진다 ArrayList 선언 , 초기화 ArrayList 선언 타입 이름 private ArrayList voArrayList; //ArrayList 선언 타입 이름 private ArrayList vo..

JAVA 2022.03.13

2022.03.13 UI & Main

저는 개인적으로 UI 쪽이 먼가 가장 복잡하게 느껴졌습니다 이번 투표 시스템뿐 아니라 다른 로직을 만들 때도 항상 UI 쪽에서 멍~해졌던 것 같습니다 이번 투표 시스템을 만들 때도 UI를 만들 때 정말.... 많아진 Class 때문에 어디에 머가 있었지.... 이게 무슨 기능이었지... 하면서 머리가 뒤죽박죽이 되어버렸습니다.... 사용자야 UI 들어간다 @RequiredArgsConstructor public class VoteUI { @NonNull private VoteService voteService; @NonNull private VoterService voterService; @NonNull private CandidateService candidateService; @NonNull priv..