package cz.muni.fi.bronchus.questions;
import java.awt.Color;
/**
* Item of the response processing. Includes the condition and its feedback and
* point's value
* @author xudrzal
*/
public class ResProcessingItem implements Comparable {
/**
* Indicates whether is auto-generated or created by user
*/
private boolean isGenerated;
/**
* Text of the condition
*/
private String condition;
/**
* Point value
*/
private int points;
/**
* Text of the feedback
*/
private String feedback;
/**
* Creates a new instance of ColoredRespCondition
* @param s text of condition
* @param i points value
* @param isGenerated True if generated otherwise false
*/
public ResProcessingItem(String s, int i, boolean isGenerated) {
condition=s;
points=i;
feedback="";
this.isGenerated=isGenerated;
}
/**
* Setter method for the text of condition
* @param s text of condition
*/
public void setCondition(String s) { this.condition=s; }
/**
* Getter method for the text of condition
* @return text of condition
*/
public String getCondition() { return condition; }
/**
* Setter method for the points value
* @param i points value
*/
public void setPoints(int i) { points=i; }
/**
* Getter method for the points value
* @return points value
*/
public int getPoints() { return points; }
/**
* Setter method for the text of feedback
* @param s text of feedback
*/
public void setFeedback(String s) { this.feedback=s; }
/**
* Getter method for the text of feedback
* @return feedback
*/
public String getFeedback() { return feedback; }
/**
* Method neccesarry for sorting collection of ResProcessingItem. Compare two
* items according their points value. Generated item has always greater value
* of points then non-generated.
* @param o ResProcessingItem to be compared with
* @return 0 if points value is the same
* value >0 if the points value of o is greater then this items's points value
* value <0 if the points value of this item is greater then points value of o
*/
public int compareTo(Object o) {
ResProcessingItem crcToCompare = (ResProcessingItem) o;
int bodyToCompare = crcToCompare.getPoints();
if (crcToCompare.isGenerated())
bodyToCompare = Integer.MAX_VALUE;
int bodythis = getPoints();
if (isGenerated)
bodythis = Integer.MAX_VALUE;
return(bodyToCompare - bodythis);
}
/**
* Creates copy of an object with the same values of attributtes
* @return new ResProcessingItem object
*/
public ResProcessingItem copy() {
ResProcessingItem crcNew = new ResProcessingItem(condition, points, isGenerated);
crcNew.feedback = feedback;
return(crcNew);
}
/**
* Getter method for the isGenerated switch
* @return True if generated otherwise false
*/
public boolean isGenerated() { return isGenerated; }
/**
* Setter method for the isGenerated switch
* @param a True if generated otherwise false
*/
public void setGenerated(boolean a) { isGenerated=a; }
}