Advertisement
rekenber

Simple program in Vala, with errors.

Mar 25th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.58 KB | None | 0 0
  1. class test0
  2. {
  3.   /* Error upon compiling:
  4.       test0.vala:9.5-9.22: error: Access to instance member `test0.test_exec' denied
  5.            test0.test_exec(q);
  6.            ^^^^^^^^^^^^^^
  7.       Compilation failed: 1 error(s), 0 warning(s)
  8.   */
  9.   public static void main(string[] args)
  10.   {
  11.     test0 argh = new test0();
  12.     stdout.printf("Greetings! How many cycles would you like? INPUT: ");
  13.     int q=0;
  14.     stdin.scanf("%d", out q);
  15.     test0.test_exec(q);
  16.   }
  17.  
  18.  
  19.   public void test_exec(int q)
  20.   {
  21.     char choice;
  22.     stdout.printf("Iterative or Recursive [I/R]? INPUT: ");
  23.     stdin.scanf("%c", out choice);
  24.     if(choice == 'I' || choice == 'i' && choice =='R' || choice == 'r')
  25.     {
  26.       stdout.printf("--START--\n");
  27.       if(choice == 'I' || choice == 'i')
  28.       {
  29.         stdout.printf("Processing cycles iteratively.");
  30.         iter_cycle(q);
  31.       }
  32.       if(choice == 'R' || choice == 'r')
  33.       {
  34.         stdout.printf("Processing cycels recursively.");
  35.         recur_cycle(q);
  36.       }
  37.     }
  38.     else
  39.     {
  40.       test_exec(q);
  41.     }
  42.   }
  43.  
  44.   public void iter_cycle(int q)
  45.   {
  46.     for(int red = q; red > 0 || q > 0 ; red--)
  47.     {
  48.       stdout.printf("Cycle %d\n", red);
  49.       if(red == 0 && q != 0)
  50.       {
  51.         red = q--;
  52.         stdout.printf("--NEXT--\n");
  53.       }
  54.     }
  55.   }
  56.  
  57.   public void recur_cycle(int q)
  58.   {
  59.     for(int red=q; red > 0; red--)
  60.     {
  61.       stdout.printf("Cycle %d\n", red);
  62.       if(red == 0 && q != 0)
  63.       {
  64.         red = q--;
  65.         stdout.printf("--NEXT--\n");
  66.         recur_cycle(q);
  67.       }
  68.     }
  69.   }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement