Interface Mirror

Proper Solutions to Software Development Problems

  Home  |   Contact  |   Syndication    |   Login
  18 Posts | 8 Stories | 16 Comments | 1 Trackbacks

News



Article Categories

Archives

Post Categories

Link

This is a sample calculator to explore more on AGI

using System;
using AGI;
namespace AsteriskGeeks
{
      public class Program
      {
         static void Main ( string [ ] args )
         {
            MonoTone mono = new MonoTone ();
            Keypad key = new Keypad ();
            //
            // Getting input for numbers
            //
            String firstNumber = mono . GetData ( "Samples/PleaseEnterYourFirstNumber" , 10000 , 1 );
            String secondNumber = mono . GetData ( "Samples/PleaseEnterYourFirstNumber" , 10000 , 1 );
            //
            // Getting input for type of Operation.
            // 1 for +
            // 2 for *
            // 3 for -
            // 4 for /
            //
            String operation = mono . GetData ( "Samples/PleaseEnterYourFirstNumber" , 10000 , 1 );
            int result = 0;
            switch ( operation )
            {
               case "1"
                  result =
int . Parse ( firstNumber ) + int . Parse ( secondNumber ); 
                  break;
            case "2"
                  result =
int . Parse ( firstNumber ) * int . Parse ( secondNumber ); 
                  break;
            case "3"
                  result =
int . Parse ( firstNumber ) - int . Parse ( secondNumber ); 
                  break;
            case "4":
                  if ( int.Parse (secondNumber) != 0 )
                  {
                     result =
int . Parse ( firstNumber ) / int . Parse ( secondNumber );
                  }
                 else
                  {
                    mono . StreamFile (
"Samples/SorryError","", out key);
                  }
                  break;
             }
            bool done = mono . StreamFile ( "Samples/PleaseEnterYourDesiredOperation" , "" , out key );
            if ( done )
            {
                  mono . StreamFile (
"Samples/ResultOfOperationFor" , "" , out key );
                  // If result is less than Zero, then a Negative must be said
                  if ( result < 0 )
                  {
                        mono . StreamFile (
"Samples/Minus" , "" , out key );
                  }
                  mono . StreamFile (
"digits/"+result , "" , out key );
            }
            mono . HangUp ();
            }
      }
}

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Tuesday, March 06, 2007 6:48 PM