Random Person

Shows the use of the randomNamesPronouns.pl macro

Complete Code

Download file: RandomPerson.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'randomPerson.pl', 'PGcourse.pl');

Preamble

We need to load randomPerson.pl macro

($p1, $p2, $p3) = randomPerson(n => 3);

$n = random(20, 30, 2);
$c = random(4,  8,  2);

Setup

The macro randomPerson.pl provides functionality to

  • select a random name from a user-defined or default list with pronouns.
  • provide correct pronouns as well as verb conjugation.

Calling randomPerson(n => 3) selects 3 unique random persons.

See the random person documentation for more information.

BEGIN_PGML
[$p1] has a ribbon of length [$n] cm.  [$p1->They] [$p1->verb('cut')]
[$c] cm off the ribbon and [$p1->verb('give')] the piece to [$p1->their]
friend [$p2].

[$p1] then [$p1->verb('divide')] the rest in half and [$p1->verb('give')]
half to [$p1->their] friend [$p3].

How much ribbon [$p1->do] [$p1] have left? [___]{Real(($n-$c)/2)}
END_PGML

Statement

The objects $p1, $p2 and $p3 are Person objects. A Person object’s name method can be called to obtain the person’s name. A Person object is “stringified” to the name as well. So [$p1] can be used in PGML to obtain the name.

There are a couple of ways to determine pronouns. One method is to call the subject, possessive, possession, and object methods of a Person to obtain pronouns referring to the person in various parts of speech. There are also capitalized versions of those methods to obtain capitalized pronouns.

Alternatively, a more-natural set of methods, they, them, their and theirs will generate the correct subject, object, possession, possesive forms of the pronoun.

In addition, there is a verb method to conjugate most verbs as well as some irregular ones, like do which returns the correct conjugation of “to do”.

Note: when writing problems using randomPerson in the Problem Editor, use the “Randomize Seed” button to ensure that the proper pronouns are used for all pronouns.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.