1 7 package com.inversoft.verge.examples.madlib; 8 9 10 18 public class MadLibFillin implements Comparable { 19 private boolean word; 20 private int index; 21 private String caption; 22 private String format; 23 private int startIndex; 24 private int endIndex; 25 26 27 30 public MadLibFillin(boolean word, int index, String caption, String format, 31 int startIndex, int endIndex) { 32 this.word = word; 33 this.index = index; 34 this.caption = caption; 35 this.startIndex = startIndex; 36 this.endIndex = endIndex; 37 } 38 39 40 45 public int getIndex() { 46 return index; 47 } 48 49 54 public boolean isWord() { 55 return word; 56 } 57 58 63 public String getCaption() { 64 return caption; 65 } 66 67 72 public String getFormat() { 73 return format; 74 } 75 76 81 public int getStartIndex() { 82 return startIndex; 83 } 84 85 90 public int getEndIndex() { 91 return endIndex; 92 } 93 94 101 public int compareTo(Object object) { 102 MadLibFillin fillin = (MadLibFillin) object; 103 104 if (word != fillin.isWord()) { 106 return (word) ? 1 : -1; 107 } 108 109 return index - fillin.getIndex(); 110 } 111 112 118 public boolean equals(Object object) { 119 if (this == object) { 120 return true; 121 } 122 123 if (!(object instanceof MadLibFillin)) { 124 return false; 125 } 126 127 final MadLibFillin madLibFillin = (MadLibFillin) object; 128 129 return ((index == madLibFillin.index) && (word == madLibFillin.word)); 130 } 131 132 137 public int hashCode() { 138 int result; 139 result = (word ? 1 : 0); 140 result = 119 * result + index; 141 142 return result; 143 } 144 }
| Popular Tags
|