import java.util.Scanner;

/**
 * Class that represents an Invoice and provides methods for accessing invoice entries.
 *   @author Dave Reed
 *   @version 8/24/24
 */
public class Invoice {
  private String customerID;
  private String date;
  private int units;
  private double pricePerUnit;
  private String salesPerson;
  
  /**
   * Constructs an invoice with the provided entries.
   *   @param date the date of the invoice
   *   @param customerID the customer ID
   *   @param units the number of units purchased
   *   @param pricePerUnit the price per unit (in dollars)
   *   @param salesPerson the salesperson ID
   */
  public Invoice(String date, String customerID, int units,
		         double pricePerUnit, String salesPerson) {
	  this.date = date;
	  this.customerID = customerID;
	  this.units = units;
	  this.pricePerUnit = pricePerUnit;
	  this.salesPerson = salesPerson;
  }
  
  /**
   * Constructs an invoice, reading entries from the specified input stream.
   *   @param input the input stream for the invoice entries
   */
  public Invoice(Scanner input) {
	  this(input.next(), input.next(), input.nextInt(),
		   input.nextDouble(), input.next());
  }
  
  /**
   * Accessor method for customer ID.
   *   @return the customer ID
   */
  public String getCustomerID() {
	  return this.customerID;
  }
  
  /**
   * Accessor method for invoice date.
   *   @return the date (in the form MM-DD-YYYY)
   */
  public String getDate() {
	  return this.date;
  }
  
  /**
   * Accessor methods for the number of units sold.
   *   @return the number of units
   */
  public int getUnits() {
	  return this.units;
  }
  
  /**
   * Accessor method for the unit price.
   *   @return the price per unit (in dollars)
   */
  public double getPricePerUnit() {
	  return this.pricePerUnit;
  }
  
  /**
   * Accessor method for salesperson ID.
   *   @return the salesperson ID
   */
  public String getSalesPerson() {
	  return this.salesPerson;
  }
  
  /**
   * Converts the invoice into a single String (e.g., for printing).
   *   @return the String representation of the invoice
   */
  public String toString() {
	  return this.getDate() + " " + this.getCustomerID() + " " + 
             this.getUnits() + " " + this.getPricePerUnit() + " " +
			 this.getSalesPerson();
  }
}
