Listing 3: Traces the telephone call through various stages from origination to termination

class RunCall
{
public:
  void run()
  {
    // create a call object with originating 
    // and terminating numbers
    SimpleCall call( "630-979-2001",
                     "630-979-2000" );
  
    // Start the call. This will put us 
    // in a transient state
    call.inputMakeCall();
    
    // Force an error to occur -- i.e., 
    // the "make call" input is not allowed
    // in the transient state.
    call.inputMakeCall();

    // Simulate a network route complete input
    call.inputRouteComplete();
  
    // Simulate the called party going off hook
    call.inputAnswer();

    // Simulate the called party hanging up
    call.inputDisconnectCalled();

    // Simulate the called party going back off hook
    call.inputAnswer();

    // Simulate the calling party going on hook
    call.inputDisconnectCalling();

    // Simulate call billing at end of call
    call.inputBillCall();

    // Done with call
    // WATCH@ call
  }
};

main()
{
  RunCall r;
  
  try
  {
    r.run();
    LogStore::GetInstance()->outputAll(cout);
  }
  catch( CallStateException& ex )
  {
    // ERROR@ MAJOR ex.getMsg().c_str()
  }
 }
— End of Listing —