import java.io.BufferedReader;
import java.io.EOFException;
import java.io.IOException;

public class Product
{  /**
      Constructs a product with empty name and 0 price and
      score.
   */
   public Product()
   {  name = "";
      price = 0;
      score = 0;
   }
   
   /**
      Constructs a product with the given name, price and 
      score.
      @param aName product name
      @param aPrice product price
      @param aScore product score between 0...100
   */
   public Product(String aName, double aPrice, int aScore)
   {  name = aName;
      price = aPrice;
      score = aScore;
   }

   /**
      Reads a product from a buffered reader.
      @param in the reader
      @return true if a product was successfully read, false
      if end of input was detected
   */
   public boolean read(BufferedReader in) 
      throws IOException
   {  // read product name
      
      name = in.readLine();
      if (name == null) return false; 

      // read product price

      String inputLine = in.readLine();
      if (inputLine == null)
         throw new EOFException
            ("EOF when reading price");
      price = Double.parseDouble(inputLine);

      // read product score

      inputLine = in.readLine();
      if (inputLine == null)
         throw new EOFException
            ("EOF when reading score");
      score = Integer.parseInt(inputLine);
      return true;
   }

   /**
      Returns the product name.
      @return the product name
   */
   public String getName()
   {  return name;
   }
   
   /**
      Returns the product price.
      @return the product price
   */
   public double getPrice()
   {  return price;
   }
   
   /**
      Returns the product score.
      @return the product score
   */
   public int getScore()
   {  return score;
   }
   
   /**
      Sets the product price.
      @param newPrice the new product price
   */
   public void setPrice(double newPrice)
   {  price = newPrice;
   }
   
   private String name;
   private double price;
   private int score;
}

