Visitador: added switchStmt with breaks

This commit is contained in:
Carlos Galindo 2019-04-03 15:34:25 +02:00
commit 137d01938c
Signed by untrusted user who does not match committer: kauron
GPG key ID: 83E68706DEE119A3
4 changed files with 125 additions and 1 deletions

View file

@ -0,0 +1,28 @@
package mytest;
public class BasicSwitch {
public static void main(String[] args) {
int x = Integer.valueOf(args[0]);
int y = -1;
switch (x) {
case 1:
y = 10;
break;
case 2:
y = 20;
break;
case 3:
y = 30;
break;
case 4:
case 5:
y = 100;
break;
case 6:
System.err.println("Error");
case 10:
y = 0;
}
System.out.println(y);
}
}

View file

@ -0,0 +1,23 @@
package mytest;
public class BasicSwitchDefault {
public static void main(String[] args) {
int x = Integer.valueOf(args[0]);
int y;
switch (x % 3) {
case 0:
y = 10;
break;
case 1:
y = 20;
break;
case 2:
y = 30;
break;
default:
y = -1;
break;
}
System.out.println(y);
}
}

View file

@ -0,0 +1,16 @@
package mytest;
public class BasicSwitchNoBreak {
public static void main(String[] args) {
String res = "";
switch (args[0]) {
case "a":
res = "abc";
case "b":
res = "bac";
case "c":
res = "cab";
}
System.out.println(res);
}
}