[問題] 關於郵遞區號的判別
各位大大好~
我在處理從地址判斷郵遞區號 3 或 5 碼的時候
再處理前3碼部分就已經完成
就在最後的門號部份的判定
不太清楚該怎麼實作
可以有人提供想法嗎
我的想法是
public interface DoorPlateMatch {
public boolean isMatchDoorPlate(String address);
} ---> 這個用來判別輸入地址的門號是否符合
public interface PlateStrategy {
public boolean isMatchZipcodeFormat(String plate);
public DoorPlateMatch getDoorPlateMatch();
} ---> 這個用來匯入規則時~所對應的且要提供門號符合的元件
public class DoorPlateFacade {
public static DoorPlateMatch getDoorPlateMatch(String doorplateformat){
for(int i=0;i<plateStrategys.length;i++){
if(plateStrategys[i].isMatchZipcodeFormat(doorplateformat)){
return plateStrategys[i].getDoorPlateMatch();
}
}
return null;
}
static PlateStrategy [] plateStrategys = new PlateStrategy[]{
new PlateStrategy(){
/* 全 */
public DoorPlateMatch getDoorPlateMatch() {
return new DoorPlateMatch(){
public boolean isMatchDoorPlate(String address) {
return true;
}
};
}
public boolean isMatchZipcodeFormat(String plate) {
// TODO 自動產生方法 Stub
return plate.trim().equals("全");
}
}
,new PlateStrategy(){
/* 單全 */
public DoorPlateMatch getDoorPlateMatch() {
return new DoorPlateMatch(){
public boolean isMatchDoorPlate(String address) {
待實作
return true;
}
};
}
public boolean isMatchZipcodeFormat(String plate) {
// TODO 自動產生方法 Stub
return plate.trim().equals("單全");
}
}
};
} ----> 處理匯入的規則及決定是否有適當的門號判別元件
謝謝~~
以下為由郵局所提供的區碼判別規則的部份
10058,台北市,中正區,八德路1段,全
10079,台北市,中正區,三元街,單全
10070,台北市,中正區,三元街,雙 48號以下
10079,台北市,中正區,三元街,雙 50號以上
10068,台北市,中正區,大埔街,單 17號以上
.......
(可以在郵局下載此份規則)
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.29.28.137
推
10/01 14:31, , 1F
10/01 14:31, 1F
→
10/01 15:27, , 2F
10/01 15:27, 2F
推
10/01 23:17, , 3F
10/01 23:17, 3F
推
10/02 00:44, , 4F
10/02 00:44, 4F
→
10/02 09:35, , 5F
10/02 09:35, 5F
→
10/02 09:37, , 6F
10/02 09:37, 6F
推
10/02 11:03, , 7F
10/02 11:03, 7F
推
10/02 11:05, , 8F
10/02 11:05, 8F
→
10/02 14:49, , 9F
10/02 14:49, 9F
推
10/02 14:51, , 10F
10/02 14:51, 10F
推
10/02 23:59, , 11F
10/02 23:59, 11F
→
10/03 00:02, , 12F
10/03 00:02, 12F