/**
   The Stock class holds data about a stock.
	@author: Tony Gaddis - modified by Elizabeth Adams
	@version 1.1
*/

public class Stock2
{
   private String symbol;     // Trading symbol of stock
   private double sharePrice; // Current price per share

   /**
      explicit value constructor

      @param sym The stock's trading symbol.
      @param price The stock's share price.
   */

   public Stock2(String sym, double price)
   {
      this.symbol = sym;
      this.sharePrice = price;
   }
   
   /**
      getSymbol method
      @return The stock's trading sysmbol.
   */
   
   public String getSymbol()
   {
      return this.symbol;
   }
   
   /**
      This method will return the object's sharePrice
      @return price of a share
   */
   
   public double getSharePrice()
   {
      return this.sharePrice;
   }

   /**
      toString method
      @return A string indicating the object's
              trading symbol and share price.
   */
   
   public String toString()
   {
      // Create a string describing the stock.
      String str = "Trading symbol: " + this.symbol +
                   "\nShare price: " + this.sharePrice;
      
      // Return the string.
      return str;
   }

   /**
      The equals method compares two Stock objects.
      @param object2 A Stock object to compare to the
                     calling Stock object.
      @return true if the argument object is equal to
                   the calling object.
   */

   public boolean equals(Stock2 object2)
   {
      boolean status;
      
      // Determine whether this object's symbol and
      // sharePrice fields are equal to object2's
      // symbol and sharePrice fields.
      if (this.symbol.equals(object2.symbol) &&
          this.sharePrice == object2.sharePrice)
         status = true;  // Yes, the objects are equal.
      else
         status = false; // No, the objects are not equal.
      
      // Return the value in status.
      return status;
   }
}
