root/InOutExpositor/oAsp.pde

Revision 5972babe7c40454704b75ea69ba2e12d80927eaa, 2.5 kB (checked in by Robin Gareus <robin@…>, 3 years ago)

fixed expositor to compile w/processing-1.0.9

  • Property mode set to 100644
Line 
1////////////////////////////////////////////////////////
2// determine IN
3class Aspiration {
4  boolean on ;
5  int type ;
6  String name ;
7  String descr ;
8
9  int N ;
10  Vector P ;
11  Vector T ;
12
13  Aspiration(int t, String vals) {
14    type = t ;
15    setString( vals ) ;
16  }
17  ///////////////////////////////////////////////////
18  void setString( String inStr ) {
19    if(!inStr.equals("")) {
20      try{
21        on = false ;
22        String[] pl = split(inStr,aSepa) ;
23        N = -1 ;
24        P = new Vector() ;
25        T = new Vector() ;
26        for(int p=0;p<pl.length;p++) { // for all given parameter, get param & value
27          String[] spl = split(pl[p],"=") ;
28          String par = spl[0] ;
29          String val = spl[1] ;
30          //////////////////////////////////////////
31          if(par.equals("N")) {
32            N = int(val) ;
33            if(N!=0) on = true ;
34          }
35          if(par.equals("P")) P = makeTagsFromString(val) ;
36          if(par.equals("T")) T = makeTagsFromString(val) ;
37          //////////////////////////////////////////
38        }
39      }
40      catch(Exception e) {
41        print("VOLONTE IN : Parsing problem\n") ;
42        P=new Vector() ;
43        T=new Vector() ;
44      }
45    }
46  }
47    ///////////////////////////////////////////////////
48    void addSatisfaction( String inLogin, int val ) {
49        addTagInVector(P, inLogin, val) ;
50    }
51  ///////////////////////////////////////////////////
52  String getString() {
53    String res = "" ;
54    if(N!=-1) res += "N="+N+aSepa ;
55    if(P.size()!=0) res += "P="+makeStringFromTags(P)+aSepa ;
56    if(T.size()!=0) res += "T="+makeStringFromTags(T)+aSepa ;
57    if(res.length()!=0) res = res.substring(0,res.length()-1) ;
58    return res ;
59  }
60  ////////////////////////////////////////////////////
61  float howMuchWanted( int k ) { // Big value if this(aspiration) loves Client(i) for that type
62    float res = 0 ;
63    Client copin = getClient(k) ;
64    //////////////////////////////////// Checks people
65    for(int i=0;i<P.size();i++) {
66      if( ((Tag)P.elementAt(i)).tag.equals( copin.login ) ) res += 10*((Tag)P.elementAt(i)).val ;   
67    }
68    //////////////////////////////////// Checks tags
69    for(int i=0;i<T.size();i++) {
70      if( ((Tag)T.elementAt(i)).isListedIn( copin.out[type].T ) ) res += 5*((Tag)T.elementAt(i)).val ;   
71    }
72    return res ;
73  }
74  int getWantedNumber() { // return N (or 1 if not defined)
75    if(N==-1) return 1 ;
76    else return N ;
77  }
78}
79////////////////////////////////////////////////////////
80
81
82
83
Note: See TracBrowser for help on using the browser.