Perfect Developer basic tutorial 2 This page last modified 2011-10-29 (JAC)

Enumeration classes Quiz

1. Given the following definition:

  class TicketType ^= enum child, student, adult, seniorCitizen end

which of the following expressions yield true ?

  1. child@TicketType = lowest TicketType
  2. child@TicketType < adult@TicketType
  3. >adult@TicketType = seniorCitizen@TicketType
  4. >(>student@TicketType) = highest TicketType
  5. <child@TicketType = seniorCitizen@TicketType

All except the last one are true. The last expression violates the precondition of the unary < operator, because child@TicketType has no predecessor.


2. Using the same definition as above, why are you likely to see an error message if you use the expression student < adult in a Perfect source file?

When you refer to the members of an enumeration class, you must qualify them with the class name.
You probably meant to say student@TicketType < adult@TicketType instead.

If you separately declared a variable, constant or parameter called student and another called adult , the expression might well be valid; although reusing names in this way can be confusing and is not recommended.