package com.aragaer.jtt;

import android.content.Context;
import android.content.res.Resources;

public class JTTHour {
    public static final String Glyphs[] = { "酉", "戌", "亥", "子", "丑", "寅", "卯",
            "辰", "巳", "午", "未", "申" };

    public final boolean isNight;
    public final int num; // 0 to 11, where 0 is hour of Cock and 11 is hour of Monkey
    public final int strikes;
    public int fraction; // 0 to 99

    private static final int num_to_strikes(int num) {
        return 9 - ((num - 3) % 6);
    }

    public JTTHour(int num) {
        this(num, 0);
    }

    public JTTHour(int n, int f) {
        num = n;
        isNight = n < 6;
        strikes = num_to_strikes(n);
        fraction = f;
    }

    public static class StringsHelper {
        private final String DayHours[], NightHours[];
        private final String Hours[], HrOf[];

        public String getHour(int num) {
            return Hours[num];
        }
        
        public String getHrOf(int num) {
            return HrOf[num];
        }

        public StringsHelper(Context ctx) {
            Resources r = ctx.getResources();
            DayHours = r.getStringArray(R.array.day_hours);
            NightHours = r.getStringArray(R.array.night_hours);
            HrOf = r.getStringArray(R.array.hour_of);
            Hours = new String[12];
            System.arraycopy(NightHours, 0, Hours, 0, 6);
            System.arraycopy(DayHours, 0, Hours, 6, 6);
        }

        public int name_to_num(String name) {
            int i;
            for (i = 0; i < 6; i++)
                if (NightHours[i] == name)
                    return i;
            for (i = 0; i < 6; i++)
                if (DayHours[i] == name)
                    return i + 6;
            return -1;
        }

        public JTTHour makeHour(String hour) {
            return makeHour(hour, 0);
        }

        public JTTHour makeHour(String hour, int fraction) {
            return new JTTHour(name_to_num(hour), fraction);
        }
    }
}

@@ -19,16 +19,43 @@
 r.jtt;%0A%0A
+import java.util.HashMap;%0A%0A
 import a
@@ -840,16 +840,33 @@
 tHours%5B%5D
+, Hours%5B%5D, HrOf%5B%5D
 ;%0A      
@@ -885,30 +885,71 @@
 nal 
-String Hours%5B%5D, HrOf%5B%5D
+HashMap%3CString, Integer%3E H2N = new HashMap%3CString, Integer%3E(12)
 ;%0A%0A 
@@ -1550,93 +1550,21 @@
     
-%7D%0A%0A
     
-    public int name_to_num(String name) %7B%0A            int i;%0A            
 for (
+int 
 i = 
@@ -1562,33 +1562,34 @@
 (int i = 0; i %3C 
-6
+12
 ; i++)%0A         
@@ -1599,34 +1599,29 @@
     
-if (NightHours%5Bi%5D == name)
+H2N.put(Hours%5Bi%5D, i);
 %0A   
@@ -1621,36 +1621,35 @@
 i);%0A        
-    
+%7D%0A%0A
         
 return i;%0A  
@@ -1640,150 +1640,78 @@
     
-return i;%0A            for (i = 0; i %3C 6; i++)%0A                if (DayHours%5Bi%5D == name)%0A                    return i + 6;%0A            return -1
+public int name_to_num(String name) %7B%0A            return H2N.get(name)
 ;%0A  

Use hashmaps for naming