import java.util.*; public class Database { Vector dat; public Database() { dat = new Vector(); } public void addData(Data dat) { System.out.println("sdf"); this.dat.add(dat); } public String search(Data da) { System.out.println("search"); int edge =0 ; Vector base = new Vector(); edge = da.getEdgeNum(); Vector base_t = new Vector(); //エッジの数が探索同じものを探索 for(int i =0;i < dat.size();i++) { if(edge == dat.get(i).getEdgeNum()) { base.add(dat.get(i)); System.out.println("Ans"+dat.get(i).getName()); } } //角いるかを探索 if( null !=da.haveKakus()) { base_t = haveKakus(base); if(base_t.size()!=0) { base = base_t; } base_t = new Vector(); } //角の数によって分類 edge = da.getKakuNum(); System.out.println("dat edge"+edge); for(int i =0;i < base.size();i++) { if(edge == base.get(i).getKakuNum()) { base_t.add(base.get(i)); System.out.println("Ans"+base.get(i).getName()); } } if(base_t.size()!=0) { base = base_t; } if(base.size() == 1) { return base.get(0).getName(); } //角が無いかを探索 if( null == da.haveKakus()) { base_t = notKakus(base); if(base_t.size()!=0) { base = base_t; } } if(base.size() == 1) { return base.get(0).getName(); } //曲がっているかを探索 if(null !=da.haveMagarus()) { base_t =haveMagarus(base); if(base_t.size()!=0) { base = base_t; } } if(base.size() == 1) { return base.get(0).getName(); } if(null==da.haveMagarus()) { base_t = notMagarus(base); if(base_t.size()!=0) { base = base_t; } } if(base.size() == 1) { return base.get(0).getName(); } //真っ直ぐかを探索 if(null !=da.haveMaxtugus()) { base_t = haveMaxtusugus(base); if(base_t.size()!=0) { base = base_t; } } if(base.size() == 1) { return base.get(0).getName(); } if(null==da.haveMaxtugus()) { base_t = notMaxtusugus(base); if(base_t.size()!=0) { base = base_t; } } if(base.size() == 1) { return base.get(0).getName(); } int sa[] = new int[9]; for(int i= 0;i<9;i++) { sa[i] = 0; } for(int i=0;i < base.size()-1 ;i++) { try { sa[new Integer(base.get(i).getName())]++; }catch(Exception e){;} } int n=0; for(int i=1;i<9;i++) { if(sa[n] < sa[i]) { n = i; } } Integer aa = new Integer(n); return aa.toString(); } public Vector haveKakus(Vector base) { Vector base_temp = new Vector(); for(int i= 0; i notKakus(Vector base) { Vector base_temp = new Vector(); for(int i= 0; i haveMagarus(Vector base) { Vector base_temp = new Vector(); for(int i= 0; i notMagarus(Vector base) { Vector base_temp = new Vector(); for(int i= 0; i notMaxtusugus(Vector base) { Vector base_temp = new Vector(); for(int i= 0; i haveMaxtusugus(Vector base) { Vector base_temp = new Vector(); for(int i= 0; i