Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITEM 35. ordinal 메서드 대신 인스턴스 필드를 사용하라 #62

Open
sypark9646 opened this issue Apr 12, 2021 · 0 comments
Open
Assignees
Labels
Assignment Something to submit

Comments

@sypark9646
Copy link
Collaborator

아래 코드를 enum 과 인스턴스 필드를 사용하여 중복을 제거 해 봅시다.

class Distance{

    private int east;
    private int west;
    private int north;
    private int south;


    public void setEast(int east){ this.east = east; }
    public void setWest(int west){ this.west = west; }
    public void setNorth(int north){ this.north = north; }
    public void setSouth(int south){ this.south = south; }


    public int getEast() { return east; }
    public int getWest() { return west; }
    public int getNorth() { return north; }
    public int getSouth() { return south; }
}

출처: https://effectiveprogramming.tistory.com/entry/enum-을-배열의-인덱스로-활용하는-방법

@sypark9646 sypark9646 added the Assignment Something to submit label Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Assignment Something to submit
Projects
None yet
Development

No branches or pull requests

4 participants