001    package org.dllearner.examples;
002    
003    import org.dllearner.core.owl.Individual;
004    
005    public class KRKPiece {
006    
007            // REMEMBER
008            // FILES are letters
009            // RANKS are numbers
010            public Individual id;
011            public String file;
012            public int rank;
013            
014            public KRKPiece(Individual id, String file, int rank) {
015                    super();
016                    this.id = id;
017                    this.file = file;
018                    this.rank = rank;
019            }
020            
021            public int getRankDistance(KRKPiece p)
022            {
023                    int otherrank=p.rank;
024                    if(this.rank>otherrank)
025                            return this.rank-otherrank;
026                    else if(this.rank==otherrank){
027                            return 0;
028                    }else return otherrank-this.rank;
029                    
030            }
031            public boolean meHasLowerRankThan(KRKPiece p){
032                    int otherrank=p.rank;
033                    if(this.rank<otherrank)
034                            return true;
035                    else return false;
036            }
037            
038            public int getFileDistance(KRKPiece p)
039            {
040                    int otherFile=letterToNumber(p.file);
041                    int meFile=letterToNumber(this.file);
042                    
043                    if(meFile>otherFile)
044                            return meFile-otherFile;
045                    else if(meFile==otherFile){
046                            return 0;
047                    }else return otherFile-meFile;
048                    
049            }
050            public boolean meHasLowerFileThan(KRKPiece p){
051                    int otherFile=letterToNumber(p.file);
052                    int meFile=letterToNumber(this.file);
053                    
054                    if(meFile<otherFile)
055                            return true;
056                    else return false;
057            }
058            
059            private int letterToNumber(String s){
060                    if(s.equals("a"))
061                            return 1;
062                    else if(s.equals("b"))
063                            return 2;
064                    else if(s.equals("c"))
065                            return 3;
066                    else if(s.equals("d"))
067                            return 4;
068                    else if(s.equals("e"))
069                            return 5;
070                    else if(s.equals("f"))
071                            return 6;
072                    else if(s.equals("g"))
073                            return 7;
074                    else if(s.equals("h"))
075                            return 8;
076                    
077                    return 0;
078            }
079            
080    }