From: jihoonl Date: Mon, 2 Nov 2009 05:26:35 +0000 (+0000) Subject: contains() method X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e3b58a375a4d76ce44d538876a5260c7a3672923;p=IRC.git contains() method --- diff --git a/Robust/src/ClassLibrary/String.java b/Robust/src/ClassLibrary/String.java index 07632bec..864574f0 100644 --- a/Robust/src/ClassLibrary/String.java +++ b/Robust/src/ClassLibrary/String.java @@ -400,6 +400,27 @@ public class String { splitted.addElement(tmpStr); return splitted; + } + + public boolean contains(String str) + { + int i,j; + char[] strChar = str.toCharArray(); + int cnt; + + for(i = 0; i < count; i++) { + if(value[i] == strChar[0]) { + cnt=0; + for(j=0; j < str.length() && i+j < count;j++) { + if(value[i+j] == strChar[j]) + cnt++; + } + if(cnt == str.length()) + return true; + } + } + + return false; } }