Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
More Jobs
Recent
Cheap ruby block templating
Bindings on caller
Initial script execution very slow and skewing results
suppress ERB newlines
Keeping the database clean
Arrays, loops, strings...
Similar virtual attributes and their getters/setter
Check type is XML Serializable
Serena Collage slideshow
Shortest regular expression for matching a subdomain.
Popular
Caching Methods
How to find max, min of three numbers?
Similar virtual attributes and their getters/setter
Shortest regular expression for matching a subdomain.
Arrays, loops, strings...
Cheap ruby block templating
Check type is XML Serializable
Bindings on caller
Apache log file sorting
Tab-Switching in jQuery
Pastable version of
Help with new methods
<div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67</pre> <pre class="sunburst"> <span style="color:#99CF50;">public </span><span style="color:#99CF50;">class</span> <span style="text-decoration:underline;">SchoolRoom</span> { <span style="color:#99CF50;">private</span> <span style="color:#9B859D;">String</span> [] students; <span style="color:#99CF50;">public </span><span style="color:#89BDFF;">SchoolRoom</span>(<span style="color:#9B859D;">String</span> [] students) { <span style="color:#3E87E3;">this</span>.students = students; } <span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;">//</span> Returns the number of students in this SchoolRoom. </span> <span style="color:#99CF50;">public </span><span style="color:#99CF50;">int</span> <span style="color:#89BDFF;">enrolment</span>() { <span style="color:#E28964;">return</span> students; } <span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;"> /**</span></span> <span style="color:#AEAEAE;font-style:italic;"> * Returns the index of the specified student in this SchoolRoom.</span> <span style="color:#AEAEAE;font-style:italic;"> * If the student appears more than once, only the index</span> <span style="color:#AEAEAE;font-style:italic;"> * of the first one (counting from the left) is returned. If the</span> <span style="color:#AEAEAE;font-style:italic;"> * student is not found in the array, -1 is returned.</span> <span style="color:#AEAEAE;font-style:italic;"> * if it is found. Returns -1 if the student is not in the array.</span> <span style="color:#AEAEAE;font-style:italic;"> <span style="color:#AEAEAE;font-style:italic;">*/</span></span> <span style="color:#99CF50;">public </span><span style="color:#99CF50;">int</span> <span style="color:#89BDFF;">indexOf</span>(<span style="color:#9B859D;">String</span> target) { } <span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;"> /**</span></span> <span style="color:#AEAEAE;font-style:italic;"> * Compares this SchoolRoom object to the object passed</span> <span style="color:#AEAEAE;font-style:italic;"> * to the method. If that object is also an instance of</span> <span style="color:#AEAEAE;font-style:italic;"> * SchoolRoom, has the same enrolment (number of students), and </span> <span style="color:#AEAEAE;font-style:italic;"> * every Student's name in that object is the same as the name </span> <span style="color:#AEAEAE;font-style:italic;"> * of every Student in the same array position in this</span> <span style="color:#AEAEAE;font-style:italic;"> * SchoolRoom, then the objects are equal.</span> <span style="color:#AEAEAE;font-style:italic;"> <span style="color:#AEAEAE;font-style:italic;">*/</span></span> <span style="color:#99CF50;">public </span><span style="color:#99CF50;">boolean</span> <span style="color:#89BDFF;">equals</span>(<span style="color:#9B859D;">Object</span> otherString) { <span style="color:#99CF50;">SchoolRoom</span> tmpObj = (<span style="color:#99CF50;">SchoolRoom</span>) o; <span style="color:#E28964;">if</span> (<span style="color:#E28964;">!</span>(o <span style="color:#E28964;">instanceof</span> <span style="color:#99CF50;">SchoolRoom</span>)) <span style="color:#E28964;">return</span> <span style="color:#3387CC;">false</span>; <span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;">//</span>return (;</span> } <span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;"> /**</span></span> <span style="color:#AEAEAE;font-style:italic;"> * Returns a new SchoolRoom which has the same students</span> <span style="color:#AEAEAE;font-style:italic;"> * as this SchoolRoom, but in reverse order. </span> <span style="color:#AEAEAE;font-style:italic;"> <span style="color:#AEAEAE;font-style:italic;">*/</span></span> <span style="color:#99CF50;">public </span><span style="color:#99CF50;">SchoolRoom</span> <span style="color:#89BDFF;">reverse</span>() { } <span style="color:#AEAEAE;font-style:italic;"><span style="color:#AEAEAE;font-style:italic;"> /**</span></span> <span style="color:#AEAEAE;font-style:italic;"> * Returns a new SchoolRoom which has all-capitals names corresponding</span> <span style="color:#AEAEAE;font-style:italic;"> * to the students in this Schoolroom. </span> <span style="color:#AEAEAE;font-style:italic;"> <span style="color:#AEAEAE;font-style:italic;">*/</span></span> <span style="color:#99CF50;">public </span><span style="color:#99CF50;">SchoolRoom</span> <span style="color:#89BDFF;">capitalize</span>() { <span style="color:#9B859D;">String</span> <span style="color:#99CF50;">SchoolRoom</span>; <span style="color:#9B859D;">System</span>.out.println(<span style="color:#99CF50;">SchoolRoom</span>.toUpperCase()); } } </pre> </div> </div> <a href="http://refactormycode.com/codes/140-help-with-new-methods" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://refactormycode.com/images/small_logo.gif" style="border:0" /></a>