/**
 * FILE: Man.java
 * AUTHOR: Ivan J Leichtling
 * INERNET: ivan@columbia.edu
 * 
 * This file defines a Man, an extension of the person class with the ability
 * to propose marraige.
 */
import java.io.* ;
import java.util.* ;
import java.awt.* ;

public class Man extends Person
{
  int       at;
  boolean   fProposed;
  Woman     wo_Possible;

  public Man( String sNomen, TextArea ta ) 
  {
    super( sNomen, ta );
    i_Sex = Person.MALE;
    at = 0;
    setProposed( false );
    setPossible( null );
  }

  public void reset()
  {
    super.reset();
    at = 0;
  }
  
  public void propose()
  {
    if( !getEngaged() ) {

      print( "Since " + getName() + " is not engaged, he proposes to the " + (at+1) + " woman on his list." );
      setPossible( (Woman) vPreferences.elementAt( at ) );
      print( new Proposal( getPossible().getName(), getName() ).toString() );
      at++;
      
      getPossible().askToMarry( this /* ME !!! */ );
      setProposed( true );
    }
  }
  
  public void accept( Woman woman )
  {
    setFiancee( woman );
    setEngaged( true );
    
    print( getName() + " is now engaged to " + 
	   fiancee.getName() );
    setPossible( null );
    setProposed( false );
  }

  public void reject()
  {
    print( new Rejection( getPossible().getName(), getName() ).toString() );
    setPossible( null );
    setProposed( false );
  }

  public boolean getProposed()
  {
    return( fProposed );
  }
  
  public void setProposed( boolean b )
  {
    fProposed = b;
  }
  
  public Woman getPossible()
  {
    return( wo_Possible );
  }
  
  public void setPossible( Woman w )
  {
    wo_Possible = w;
  }
}







