<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users299</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/299" rel="self"/>
  <title>Mark Webb</title>
  <updated>Fri Nov 09 15:17:32 -0800 2007</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor810</id>
    <published>2007-11-09T15:17:32-08:00</published>
    <title>[Java] On Cannot Ref from Static Content</title>
    <content type="html">&lt;p&gt;A way to make the class work by altering the getCount method without changing the constructor. &lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Mark Webb</name>
      <email>g4me.on@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/145-cannot-ref-from-static-content/refactors/810" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor807</id>
    <published>2007-11-09T15:00:57-08:00</published>
    <title>[Java] On Cannot Ref from Static Content</title>
    <content type="html">&lt;p&gt;Is there a way to change it without changing the constructor?&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Mark Webb</name>
      <email>g4me.on@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/145-cannot-ref-from-static-content/refactors/807" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code145</id>
    <published>2007-11-09T14:45:45-08:00</published>
    <updated>2007-11-13T22:23:23-08:00</updated>
    <title>[Java] Cannot Ref from Static Content</title>
    <content type="html">&lt;p&gt;If anyone can tell me what Ive done wrong here that would be great.&lt;/p&gt;

&lt;p&gt;Space.java:69: non-static method getCount() cannot be referenced from a static context&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;pre&gt;public class Space {
    private int count;
    private String varStr;
    private int varNum;

     
       private Space(String varStr) {
         varStr = varStr;
      }

         private Space(String varStr, int varNum) {                                                                                                        
         varNum = varNum;
      }
     
       public int getCount() { 
          return count;
      }

       public String getVarStr() {                                                                                                                
         return varStr;
      }

       public void setVarStr(String varStr) {
          varStr = varStr;
      }

       public int getVarNum() {                                                                                                          
         return varNum;
      }
  
       public void setVarNum(int varNum) {
          varNum = varNum;
      }


      /* toString */
       public String toString()
      {
         String output = &amp;quot;varNum is 1 str is A string &amp;quot;;
         return output;

      }

    /* equals method */
      public boolean equals (Object o){
         boolean result = false;
          
	  Space other;
            if (o instanceof Space){
            other = (Space)o;

            result = getVarNum() == other.getVarNum();
           }


         return result;
      }


    /*
       DRIVER
     */
    public static void main(String[] args) {
        System.out.println(&amp;quot;Space begin\n&amp;quot;);

        /* calls the class method */
         System.out.println(&amp;quot;\tgetCount= &amp;quot; +Space.getCount());

        /* calls constructor */
          Space q1 = new Space(&amp;quot;A string&amp;quot;);
          Space q2 = new Space(&amp;quot;A string&amp;quot;, 3);

        /* calls the class method again */
         System.out.println(&amp;quot;\tgetCount= &amp;quot; +Space.getCount());

        /* calls toString method  */
         System.out.println(&amp;quot;\ttoString= &amp;quot; +q1);

        /* calls your mutator method */
         q1.setVarStr(&amp;quot;Diff&amp;quot;);
         q2.setVarNum(5);

        /* calls your accessor method */
         System.out.println(&amp;quot;\tget= &amp;quot; +q1.getVarStr());
         System.out.println(&amp;quot;\tget= &amp;quot; +q2.getVarNum());


        /* calls your equals method */
         System.out.println(&amp;quot;\tequals= &amp;quot; +q1.equals(q1));
         System.out.println(&amp;quot;\tequals= &amp;quot; +q1.equals(q2));

        System.out.println(&amp;quot;\nSpace end\n&amp;quot;);
    }
}
&lt;/pre&gt;</content>
    <author>
      <name>Mark Webb</name>
      <email>g4me.on@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/145-cannot-ref-from-static-content" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor762</id>
    <published>2007-11-06T12:26:53-08:00</published>
    <title>[Java] On Help with new methods</title>
    <content type="html">&lt;p&gt;Many thanks&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Mark Webb</name>
      <email>g4me.on@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/140-help-with-new-methods/refactors/762" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code140</id>
    <published>2007-11-06T07:28:03-08:00</published>
    <updated>2007-11-22T02:33:53-08:00</updated>
    <title>[Java] Help with new methods</title>
    <content type="html">&lt;p&gt;Having some trouble with the methods, I've included some comments so you can see what I tried or intented to achieve here. &lt;/p&gt;

&lt;pre&gt;
public class SchoolRoom {
    private String [] students;
    
    public SchoolRoom(String [] students) {
        this.students = students;
    }

    // Returns the number of students in this SchoolRoom.                                       
    public int enrolment() {
       return students; 
    } 
 
    /**
     * Returns the index of the specified student in this SchoolRoom.
     * If the student appears more than once, only the index
     * of the first one (counting from the left) is returned. If the
     * student is not found in the array, -1 is returned.
     * if it is found. Returns -1 if the student is not in the array.
     */
     public int indexOf(String target) {
       

    }

    /**
     * Compares this SchoolRoom object to the object passed
     * to the method. If that object is also an instance of
     * SchoolRoom, has the same enrolment (number of students), and 
     * every Student's name in that object is the same as the name 
     * of every Student in the same array position in this
     * SchoolRoom, then the objects are equal.
     */
    public boolean equals(Object otherString) {

        SchoolRoom tmpObj = (SchoolRoom) o;

        if (!(o instanceof SchoolRoom))
            return false;

        //return (;

    }

    /**
     * Returns a new SchoolRoom which has the same students
     * as this SchoolRoom, but in reverse order. 
     */
    public SchoolRoom reverse() {

 
    }
 
    /**
     * Returns a new SchoolRoom which has all-capitals names corresponding
     * to the students in this Schoolroom. 
     */
     public SchoolRoom capitalize() {
        String SchoolRoom;

        System.out.println(SchoolRoom.toUpperCase()); 
     }
}



   
&lt;/pre&gt;</content>
    <author>
      <name>Mark Webb</name>
      <email>g4me.on@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/140-help-with-new-methods" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor727</id>
    <published>2007-11-05T08:38:20-08:00</published>
    <title>[Java] On Errors With Exception</title>
    <content type="html">&lt;p&gt;I see, I didnt instantiate the array correctly. Thank you.&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Mark Webb</name>
      <email>g4me.on@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/134-errors-with-exception/refactors/727" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code134</id>
    <published>2007-11-05T07:03:08-08:00</published>
    <updated>2007-11-05T11:58:22-08:00</updated>
    <title>[Java] Errors With Exception</title>
    <content type="html">&lt;p&gt;It compiles, although when I try to run it, I get an exception.&lt;/p&gt;

&lt;pre&gt;public class Parks {
    private String[] parkingBays;
    private int numCars;

    public Parks(int capacity) {
        parkingBays = new String[numCars];

        for (int i = 0; i &amp;lt;= parkingBays.length; i++) {
            parkingBays[i] = &amp;quot;Empty&amp;quot;;
        }
    }
    public boolean park(String car) {
        
        if (numCars &amp;gt; parkingBays.length){
            parkingBays[++numCars] = car;
        }
        else {
            return false;
        }
        return true;
    }


    /**
     * For Testing
     */
    public static void main(String [] args) {
        Parks p = new Parks(20);
        boolean spaces = true;
        while (spaces) {
            spaces = p.park(&amp;quot;car1&amp;quot;);
            spaces = p.park(&amp;quot;car2&amp;quot;);
        }
        for (String car : p.parkingBays)
            System.out.println(car);
    }
}&lt;/pre&gt;</content>
    <author>
      <name>Mark Webb</name>
      <email>g4me.on@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/134-errors-with-exception" rel="alternate"/>
  </entry>
</feed>

