title: equals method - how to override
body: <p>I need help on to override the <code>equals</code> method. I have everything working except for the <code>equals</code> method. The <code>equals</code> method that I currently have is not giving me the correct answer. I can not seem to figure out what could be the problem.  </p>
  
  <p>My Class:</p>
  
  <pre><code>package myclasses;
  
  public class Currency
  {
      private int dollars, cents;
  
      public Currency()
      {
          dollars = 0;
          cents = 0;
      }
  
      public Currency(int d, int c)
      {
          this.dollars = d;
          this.cents = c;
  
          setCents(cents);
      }
  
      public int getDollars()
      {
          return dollars;
      }
  
      public int getCents()
      {
          return cents;
      }
  
      private void setDollars(int dollars)
      {
          this.dollars = dollars;
      }
  
      private void setCents(int cents)
      {       
          while(cents &gt; 99)
          {
              cents = (cents - 100);
              dollars++;
          }
  
          this.cents = cents;
      }
  
      public void setAmount(int newDollars, int newCents)
      {
          setDollars(dollars);
          setCents(cents);
      }
  
      public void add(int dollars, int cents)
      {
          this.dollars =  dollars + getDollars();
          cents = cents + getCents();
  
          setCents(cents);
      }
  
      public boolean equals(Object dollars, Object cents)
      {
          if(this == dollars &amp;&amp; this == cents)
              return true;
  
          if(!(dollars instanceof Currency) || !(cents instanceof Currency))
              return false;
  
          Currency money = (Currency) dollars;
          Currency penny = (Currency) cents;
  
          return (this.dollars == money.dollars) &amp;&amp; (this.cents == penny.cents);
          //return Currency.dollars.equals(Currency.cents);
          //return this.equals(dollars) &amp;&amp; this.equals(cents);
  
      }
  
      public boolean isZero()
      {
          if(getDollars() == 0 &amp;&amp; getCents() == 0)
          {
              return true;
          }
          return false;
      }
  
      public String toString()
      {
          return "$" + getDollars() + "."   +
                  (getCents() &lt; 10 ? ("0" + getCents()) : getCents());
      }
  }
  </code></pre>