ALGORITHM

1076_저항

서울소시민 2017. 9. 29. 23:58
    package bj_1076;

    import java.util.Scanner;

    public class Main {
        public static void main(String[] args) {
            revolution re[] = new revolution[10];
            String dab[] = new String[3];
            int result=0;

            re[0].setRel("black",0,1);
            re[1].setRel("brown",1,10);
            re[2].setRel("red",2,100);
            re[3].setRel("orange",3,1000);
            re[4].setRel("yellow",4,10000);
            re[5].setRel("green",5,100000);
            re[6].setRel("blue",6,1000000);
            re[7].setRel("violet",7,10000000);
            re[8].setRel("grey",8,100000000);
            re[9].setRel("white",9,1000000000);

            Scanner sc = new Scanner(System.in);
            for(int i=0;i<dab.length;i++){
                dab[i] = sc.nextLine();
            }



            for(int i=0;i<re.length;i++){
                if(re[i].reRes(dab[0])!=-1)
                    result+=re[i].getRes();

                if(re[i].reRes(dab[1])!=-1)
                    result+=re[i].getRes();

                if(re[i].reMul(dab[2])!=-1)
                    result*=re[i].getMul();

            }

            System.out.println(result);


        }
    }


    class revolution{
        String color;
        int res;
        int mul;

        revolution(){
        }

        void setRel(String color, int res, int mul){
            this.color=color;
            this.res=res;
            this.mul=mul;
        }

        int getRes(){
            return this.res;
        }

        int getMul(){
            return this.mul;
        }


        int reRes(String color){
            if(this.color==color)
                return this.res;
            else
                return -1;
        }

        int reMul(String color){
            if(this.color==color)
                return this.res;
            else{
                return -1;
        }
    }
}

'ALGORITHM' 카테고리의 다른 글

1912_연속합  (0) 2017.10.10
1316_그룹단어체커  (0) 2017.10.03
집합_11723  (0) 2017.09.28
9095_1,2,3나누기  (0) 2017.09.26
11057_오르막수  (0) 2017.09.25