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!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Ultra lightweight message "popup" at top of parent element
Good way to output menu with submenu through a module?!
Moving Code from Controller to Model
Get Site Information with PHP
Help with module?!
Node.js: Calculating total filesize of 3 files
convert single itemed sub-arrays into string
Access HashMap key by value
Language Selection
Generating a list of 3 entries with the rest hidden
Popular
Good way to output menu with submenu through a module?!
Ultra lightweight message "popup" at top of parent element
Moving Code from Controller to Model
Double 'if'
Language Selection
Help with module?!
Fetch and parse feeds with feedzirra
Generating a list of 3 entries with the rest hidden
Access HashMap key by value
Node.js: Calculating total filesize of 3 files
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://www.refactormycode.com/codes/140-help-with-new-methods" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>