javaclass

tests/SwitchTest.java

150:6c5a400aeffd
2005-01-23 Paul Boddie Fixed imports.
     1 public class SwitchTest {     2      3     public int test(int x) {     4         switch (x) {     5             case 0:     6      7             case 1:     8             x = x + 10;     9             break;    10     11             case 2:    12             x = x + 20;    13             break;    14     15             default:    16             break;    17         }    18     19         return x;    20     }    21     22     public static void main(String[] args) {    23         SwitchTest test = new SwitchTest();    24         if (test.test(0) == 10) {    25             System.out.println("test.test(0) correct: " + test.test(0));    26         } else {    27             System.err.println("test.test(0) failed!");    28         }    29         if (test.test(1) == 11) {    30             System.out.println("test.test(1) correct: " + test.test(1));    31         } else {    32             System.err.println("test.test(1) failed!");    33         }    34         if (test.test(2) == 22) {    35             System.out.println("test.test(2) correct: " + test.test(2));    36         } else {    37             System.err.println("test.test(2) failed!");    38         }    39         if (test.test(3) == 3) {    40             System.out.println("test.test(3) correct: " + test.test(3));    41         } else {    42             System.err.println("test.test(3) failed!");    43         }    44     }    45 }    46     47 // vim: tabstop=4 expandtab shiftwidth=4