2017-03-26 3 views
-2

편집 : CTL 및 모델 검사 순서를 구현하는 방법에 대한 설명을 구하기 때문에 복제본이 아닙니다.상태 머신/변환 시스템을 구축하기위한 도움이 필요합니다.

자바에서 모델 검사기를 프로그래밍 중이지만 전환 시스템 설계에 박혀 있습니다. type (int, bool, string [] 또는 set, int [] 또는 set) 유형의 객체는 전환 시스템이되는 상태 목록에 추가됩니다. 그것은 (stateenumber, bool, string [] transition, new int [] state)와 같은 state와 transitions의리스트를 출력하기로되어있다. 지금은 전환 객체와 일부 추측 된 memoryid 만 인쇄하고 있습니다. 다음과 같이 보입니다 : Transition @ 11abc1234. 내 질문은 print (int, bool, string [] 또는 set, int [] 또는 set)를 만들기 위해 어떤 추가 개선 사항을 구현해야합니까? 미리 감사드립니다! 다음은 제 코드입니다 :`import java.util. *;

공용 클래스 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.*; 

공용 클래스 전환이 목록을 구현 {

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; 
} 
+3

[SomeType @ 2f92e0f4 "를 가져 오지 않고 Java 객체를 인쇄하는 방법은 무엇입니까?] (http://stackoverflow.com/questions/29140402/how-do-i-print-my-java-object- without-getting-sometype2f92e0f4) –

+0

실제로 총 statemachine을 만드는 방법에 대한 추가 설명을 검색하므로 실제로는 아닙니다. – Slow1mo

+0

네, 정말로 - 질문의 주요 부분이며 두 부분으로 된 질문을해서는 안됩니다. –

답변

-1

당신은 서명으로 Transition 클래스에 메소드를 추가 할 필요가 :

public String toString(){ 
    ... 
} 

합니다 (Object 클래스) 기본 toString() 구현은 클래스와 내부 레퍼런스의 이름을 출력합니다. toString()을 원하는대로 인쇄 할 수 있습니다.