home *** CD-ROM | disk | FTP | other *** search
- program Listing5_6;
-
- type
-
- Person = ( fps, sps, tps, fpp, spp, tpp );
- Ending = array[fps..tpp] of string;
-
- const
- ER_Nominative : Ending
- = ( 'e', 'es', 'e', 'ons', 'ez', 'ent' );
- IR_Nominative : Ending
- = ( 'is', 'is', 'it', 'issons', 'issez', 'issent');
- RE_Nominative : Ending
- = ( 's', 's', '', 'ons', 'ez', 'ent');
-
- type
- Verb = object
- Infinitive : string;
- Root : string;
- constructor Init( TheVerb : string );
- function VerbForm( E : Person ) : string; virtual;
- procedure ConjugateVerb;
- end;
-
- RE_Verb = object( Verb )
- function VerbForm( E : Person ) : string; virtual;
- end;
-
-
- IR_Verb = object( Verb )
- function VerbForm( E : Person ) : string; virtual;
- end;
-
- ER_Verb = object( Verb )
- function VerbForm( E : Person ) : string; virtual;
- end;
-
- constructor Verb.Init( TheVerb : string );
- begin
- Infinitive := TheVerb;
- Root := Copy( TheVerb, 1, (Length(TheVerb) - 2) );
- end;
-
- { This function is needed to be able to compile the .ConjugateVerb
- method }
- function Verb.VerbForm( E: Person ) : string;
- begin
- VerbForm := '';
- end;
-
- function ER_Verb.VerbForm( E : Person ) : string;
- begin
- VerbForm := Concat( Root, ER_Nominative[E] )
- end;
-
- function IR_Verb.VerbForm( E : Person ) : string;
- begin
- VerbForm := Concat( Root, IR_Nominative[E] )
- end;
-
- function RE_Verb.VerbForm( E : Person ) : string;
- begin
- VerbForm := Concat( Root, RE_Nominative[E] )
- end;
-
- procedure Verb.ConjugateVerb;
- begin
- writeln( 'Conjugation of the verb ', Infinitive, ':' );
- writeln( 'je ', VerbForm( fps ) );
- writeln( 'tu ', VerbForm( sps ) );
- writeln( 'il ', VerbForm( tps ) );
- writeln( 'nous ', VerbForm( fpp ) );
- writeln( 'vous ', VerbForm( spp ) );
- writeln( 'ils ', VerbForm( tpp ) );
- end;
-
- var
- repondre : RE_Verb;
- finir : IR_Verb;
- manquer : ER_Verb;
- begin
- repondre.Init( 'repondre' );
- finir.Init( 'finir' );
- manquer.Init( 'manquer' );
-
- repondre.ConjugateVerb;
- finir.ConjugateVerb;
- manquer.ConjugateVerb;
-
- end.
-
- { Listing 5-6 }