-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWordSig.java
More file actions
75 lines (64 loc) · 1.47 KB
/
WordSig.java
File metadata and controls
75 lines (64 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package predictive;
/**
* @author ShukriAli
* @version 5/2/2018
*/
public class WordSig implements Comparable<WordSig>{
private String words;
private String signature;
/**
* WordSig constructor take in a word and
* constructs a WordSig object with a word
* and signature
* and a signature
* @param words is a String
*/
public WordSig (String words) {
this.words = words;
this.signature = PredictivePrototype.wordToSignature(words);
}
/**
* WordSig constructor take in an empty String and signature
* then constructs a WordSig object with a word and signature
* @param words is a String
* @param signature is a String
*/
public WordSig (String words, String signature) {
this.words = "";
this.signature = signature;
}
/**
* is the getter for words
* @return returns a word
*/
public String getWords() {
return words;
}
/**
* getter for signature
* @return returns a signature
*/
public String getSignature() {
return signature;
}
/**
* compareTo method compares two signatures
* @param ws an WordSig signatures
* @return returns -1, 0 or 1 according to whether
* the current signatures is less than, equal to, or greater
* than the argument signatures, in the intended ordering
*/
public int compareTo(WordSig ws) {
int x= (this.signature.compareTo(ws.signature));
if(x>0){
return 1;
}
else if (x<0){
return -1;
}
else return 0;
}
public String toString () {
return signature + " = " + words;
}
}