-2

Edit : Not a duplicate since I seek the explanation of how i implement CTL and a model checking sequence.

I'm programming a model checker in java but im stuck in designing the transition system. An object of type (int, bool, string[] or set, int[] or set) is supposed to be added to a list of states, being the transition system. It supposed to be printing the list of states and transitions like (statenumber, bool, string[] transition, new int[] state). Right now is printing only the transition object and some memoryid i guess. Looks like this : Transition@11abc1234. My question is which further improvements shall I implements to make it print (int, bool, string[] or set, int[] or set) ? Thanks in advance! Here is my code :`import java.util.*;

public class TS {

private int i;
private boolean bool;
private static List<Transition> transitions;
State initial;
private int[] state;

TS(State initial, boolean bool, List<Transition> transitions, int[] state) 
{
    this.initial = initial;
    this.bool = bool;
    TS.transitions = transitions;
    this.state = state;
}

public State getNextState(Set<Condition> conditions) {
        for(Transition transition : transitions) {
            //boolean currentStateMatches = transition.old.equals(initial);
            //boolean conditionsMatch = transition.accepted.equals(accepted);
            if(Transition.from.equals(initial) && Transition.conditions.equals(conditions) 
                     ) {
                return transition.to;
            }
        }
        return null;
    }

public static void main(String[] args) 
{

    transitions = new Transition(1, true,  new String[] {"v"}, new int[] {2});
    transitions = new Transition(2, false, new String[] {"v"}, new int[] {1, 4});
    transitions = new Transition(3, false, new String[] {"c"}, new int[] {3});
    transitions = new Transition(4, false, new String[] {"c"}, new int[] {4});
    System.out.println(transitions);
}

}

import java.util.*;

public class Transition implements List {

 private int i;
private boolean b;
private String[] strings;
private int[] js;

public Transition(int i, boolean b, String[] strings, int[] js) {
    this.i = i;
    this.b = b;
    this.strings = strings;
    this.js = js;
}
public static State from;
 public static Set<Condition> conditions;
 public State to;

@Override
public boolean add(Transition e) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public void add(int index, Transition element) {
    // TODO Auto-generated method stub

}
@Override
public boolean addAll(Collection<? extends Transition> c) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean addAll(int index, Collection<? extends Transition> c) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public void clear() {
    // TODO Auto-generated method stub

}
@Override
public boolean contains(Object o) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean containsAll(Collection<?> c) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public Transition get(int index) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public int indexOf(Object o) {
    // TODO Auto-generated method stub
    return 0;
}
@Override
public boolean isEmpty() {
    // TODO Auto-generated method stub
    return false;
}
@Override
public Iterator<Transition> iterator() {
    // TODO Auto-generated method stub
    return null;
}
@Override
public int lastIndexOf(Object o) {
    // TODO Auto-generated method stub
    return 0;
}
@Override
public ListIterator<Transition> listIterator() {
    // TODO Auto-generated method stub
    return null;
}
@Override
public ListIterator<Transition> listIterator(int index) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public boolean remove(Object o) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public Transition remove(int index) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public boolean removeAll(Collection<?> c) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public boolean retainAll(Collection<?> c) {
    // TODO Auto-generated method stub
    return false;
}
@Override
public Transition set(int index, Transition element) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public int size() {
    // TODO Auto-generated method stub
    return 0;
}
@Override
public List<Transition> subList(int fromIndex, int toIndex) {
    // TODO Auto-generated method stub
    return null;
}
@Override
public Object[] toArray() {
    // TODO Auto-generated method stub
    return null;
}
@Override
public <T> T[] toArray(T[] a) {
    // TODO Auto-generated method stub
    return null;
}

}

import java.util.*;

public class State 

    {
    String state;
    }


public class Condition {
    String condition;
}
hippietrail
  • 15,848
  • 18
  • 99
  • 158
Slow1mo
  • 9
  • 2

1 Answers1

-1

You need to add a method to your Transition class with the signature:

public String toString(){
  ...
}

The default toString() implementation (in the Object class) just prints out the name of the class and an internal reference. You can have your toString() print out whatever you want.

Prisoner
  • 49,922
  • 7
  • 53
  • 105