home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Freeware / Programare / bluej / bluejsetup-200.exe / {app} / examples / debugdemo / Demo.java < prev    next >
Encoding:
Java Source  |  2004-09-15  |  1.1 KB  |  62 lines

  1. /**
  2.  * Class Demo - this class is used in the BlueJ tutorial for demonstrating
  3.  * the BlueJ debug functionality. It contains loops and nested method calls
  4.  * that make interesting examples to set breakpoints.
  5.  * 
  6.  * @author M. Kolling
  7.  * @version 13 August 1999
  8.  */
  9. public class Demo
  10. {
  11.     private String name;
  12.     private int answer;
  13.  
  14.     /**
  15.      * Constructor for objects of class Demo
  16.      */
  17.     public Demo()
  18.     {
  19.         name = "Marvin";
  20.         answer = 42;
  21.     }
  22.  
  23.     /** 
  24.      * Loop for a while and do some meaningless computations.
  25.      */
  26.     public int loop(int count)
  27.     {
  28.             int sum = 17;
  29.  
  30.         for (int i=0; i<count; i++) {
  31.             sum = sum + i;
  32.             sum = sum - 2;
  33.         }
  34.         return sum;
  35.     }
  36.  
  37.     /**
  38.      * Method for demonstrating single stepping with nested method call.
  39.      */
  40.     public int carTest()
  41.     {
  42.         int places;
  43.         Car myCar = new Car(2, 3);
  44.  
  45.         places = myCar.seats();
  46.         return places;
  47.     }
  48.  
  49.     public int longloop()
  50.     {
  51.         int sum = 0;
  52.  
  53.         for (int i=0; i<20000000; i++) {
  54.           sum = sum + i;
  55.           sum = sum -200;
  56.         }
  57.         return 42;
  58.     }
  59.  
  60.  
  61. }
  62.