0
DNAstrand 개체의 기본 문자열이 더 작은 문자열 (이 매개 변수가 될 것입니다)과 비교되는 프로그램에 대한 메서드를 만들려고합니다.이 메서드는 다음과 같은 패턴을 검색합니다. DNAstrand 객체의 기본. 패턴을 찾으면 DNAStrand 객체에서 패턴의 시작 위치 번호를 반환합니다. 지금까지 시도했지만 코드가 작동하지 않습니다. 여기까지 내 코드가 있습니다 (다른 메서드를 다른 메서드 내에서 사용하고 있습니다).문자열 일치하는 DNA 메서드 만들기
for(int position =0; position + substrand.getLength() < (this.getLength()- substrand.getLength() +1); position ++){
if(matchAt(substrand)){
return position;
}
} return -1;
}
protected boolean matchAt(DNAStrand substrand) {
for (int i = 0; i < (this.getLength()- substrand.getLength() +1); i++) {
if (this.getBaseAt(i) != substrand.getBaseAt(i)) {
return false;
} }return true;
}
네, 여기에 우리에게 많은 것을 보여주지는 않습니다. 나는 String을 사용하고 아마도 Pattern 클래스를 들여다 보았을 때부터 제안한다. 태그에 패턴 매칭을 포함하고 패턴에 대한 참조가 보이지 않습니다. http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html –