1 20 26 package gov.nasa.jpf.jvm.choice; 27 28 import gov.nasa.jpf.Config; 29 import gov.nasa.jpf.jvm.IntChoiceGenerator; 30 import gov.nasa.jpf.jvm.JVM; 31 32 37 public class TwoIntChoice extends IntChoiceGenerator { 38 39 int firstValue = 100; 40 int secondValue = 200; 41 42 String firstMsg = "pass"; 43 String secondMsg = "fail"; 44 45 int state = -1; 46 47 public TwoIntChoice(Config conf, String id) { 48 super(id); 49 firstValue = conf.getInt( id + ".firstValue"); 50 firstMsg = conf.getString( id + ".firstMessage"); 51 secondValue = conf.getInt( id + ".secondValue"); 52 secondMsg = conf.getString( id + ".secondMessage"); 53 } 54 55 58 public int getNextChoice(JVM vm) { 59 int ret; 60 switch (state){ 61 case 0: { 62 ret = firstValue; 63 vm.println(firstMsg); 64 break; 65 } 66 case 1: { 67 ret = secondValue; 68 vm.println(secondMsg); 69 break; 70 } 71 default: { 72 ret = 99; 73 } 74 } 75 return ret; 76 } 77 78 81 public boolean hasMoreChoices(JVM vm) { 82 return state < 1; 83 } 84 85 88 public void advance(JVM vm) { 89 state++; 90 } 92 93 } 94 | Popular Tags |