import java.io.*;
/**
* Test driver for class <code>AthleteScores</code>.
*
* @author author name
* @version 1.0.0
*/
public class TestAthleteScores {
/* Standard output stream */
private static PrintWriter stdOut = new PrintWriter(System.out, true);
/* Standard error stream */
private static PrintWriter stdErr = new PrintWriter(System.err, true);
/**
* Test driver for class <code>AthleteScores</code>.
*
* @param args not used.
*/
public static void main(String[] args) {
/* PLACE YOUR CODE HERE */
// Test the accessors.
AthleteScores score1=new AthleteScores("xiaoming",1.0,2.0,3.0);
assertTrue("1: testing method getName()",score1.getName()=="xiaoming");
assertTrue("2: testing method getScoreOne()",score1.getScoreOne()==1.0);
assertTrue("3: testing method getScoreTwo()",score1.getScoreTwo()==2.0);
assertTrue("4: testing method getScoreThree()",score1.getScoreThree()==3.0);
// Testing the mutators.
AthleteScores score2=new AthleteScores("xiaohong",0.0,0.0,0.0);
score2.setScoreOne(4.0);
assertTrue("5: testing method setScoreOne()",score2.getScoreOne()==4.0);
score2.setScoreTwo(5.0);
assertTrue("6: testing method setScoreTwo()",score2.getScoreTwo()==5.0);
score2.setScoreThree(6.0);
assertTrue("7: testing method setScoreThree()",score2.getScoreThree()==6.0);
// Test the method getMinimum.
AthleteScores score3=new AthleteScores("xiaogang",1.0,2.0,3.0);
assertTrue("8: testing method getMinimum()",score3.getMinimum()==score3.getScoreOne());
AthleteScores score4=new AthleteScores("xiaoli",2.0,1.0,3.0);
assertTrue("9: testing method getMinimum()",score4.getMinimum()==score4.getScoreTwo());
AthleteScores score5=new AthleteScores("xiaodong",2.0,3.0,1.0);
assertTrue("10: testing method getMinimum()",score5.getMinimum()==score5.getScoreThree());
// Test the method equals.
AthleteScores score6=new AthleteScores("xiaoshan",1.0,2.0,3.0);
AthleteScores score7=new AthleteScores("xiaoshan",2.0,2.0,3.0);
AthleteScores score8=new AthleteScores("xiaoshang",1.0,2.0,3.0);
TestAthleteScores a=new TestAthleteScores();
assertTrue("11: testing method equals()",score6.equals(score7));
assertTrue("12: testing method equals()",!score6.equals(score8));
assertTrue("13: testing method equals()",!score6.equals(a));
// Test the method toString.
AthleteScores score9=new AthleteScores("xiaowang",1.0,2.0,3.0);
String s1=score9.toString();
String s2=score9.getName()+","+score9.getScoreOne()+","+score9.getScoreTwo()+","+score9.getScoreThree();
assertTrue("14: testing method toString()",s1.equals(s2));
stdOut.println("done"); // Testing is finished.
}
/**
* Displays a message in the standard error stream if the value specified
* by parameter <code>condition<code> is <code>false</code>.
*
* @param message the error message.
* @param condition the test condition.
*/
public static void assertTrue(String message, boolean condition) {
if (! condition) {
stdErr.print("** Test failure ");
stdErr.println(message);
}
}
}
/**
* Test driver for class <code>AthleteScores</code>.
*
* @author author name
* @version 1.0.0
*/
public class TestAthleteScores {
/* Standard output stream */
private static PrintWriter stdOut = new PrintWriter(System.out, true);
/* Standard error stream */
private static PrintWriter stdErr = new PrintWriter(System.err, true);
/**
* Test driver for class <code>AthleteScores</code>.
*
* @param args not used.
*/
public static void main(String[] args) {
/* PLACE YOUR CODE HERE */
// Test the accessors.
AthleteScores score1=new AthleteScores("xiaoming",1.0,2.0,3.0);
assertTrue("1: testing method getName()",score1.getName()=="xiaoming");
assertTrue("2: testing method getScoreOne()",score1.getScoreOne()==1.0);
assertTrue("3: testing method getScoreTwo()",score1.getScoreTwo()==2.0);
assertTrue("4: testing method getScoreThree()",score1.getScoreThree()==3.0);
// Testing the mutators.
AthleteScores score2=new AthleteScores("xiaohong",0.0,0.0,0.0);
score2.setScoreOne(4.0);
assertTrue("5: testing method setScoreOne()",score2.getScoreOne()==4.0);
score2.setScoreTwo(5.0);
assertTrue("6: testing method setScoreTwo()",score2.getScoreTwo()==5.0);
score2.setScoreThree(6.0);
assertTrue("7: testing method setScoreThree()",score2.getScoreThree()==6.0);
// Test the method getMinimum.
AthleteScores score3=new AthleteScores("xiaogang",1.0,2.0,3.0);
assertTrue("8: testing method getMinimum()",score3.getMinimum()==score3.getScoreOne());
AthleteScores score4=new AthleteScores("xiaoli",2.0,1.0,3.0);
assertTrue("9: testing method getMinimum()",score4.getMinimum()==score4.getScoreTwo());
AthleteScores score5=new AthleteScores("xiaodong",2.0,3.0,1.0);
assertTrue("10: testing method getMinimum()",score5.getMinimum()==score5.getScoreThree());
// Test the method equals.
AthleteScores score6=new AthleteScores("xiaoshan",1.0,2.0,3.0);
AthleteScores score7=new AthleteScores("xiaoshan",2.0,2.0,3.0);
AthleteScores score8=new AthleteScores("xiaoshang",1.0,2.0,3.0);
TestAthleteScores a=new TestAthleteScores();
assertTrue("11: testing method equals()",score6.equals(score7));
assertTrue("12: testing method equals()",!score6.equals(score8));
assertTrue("13: testing method equals()",!score6.equals(a));
// Test the method toString.
AthleteScores score9=new AthleteScores("xiaowang",1.0,2.0,3.0);
String s1=score9.toString();
String s2=score9.getName()+","+score9.getScoreOne()+","+score9.getScoreTwo()+","+score9.getScoreThree();
assertTrue("14: testing method toString()",s1.equals(s2));
stdOut.println("done"); // Testing is finished.
}
/**
* Displays a message in the standard error stream if the value specified
* by parameter <code>condition<code> is <code>false</code>.
*
* @param message the error message.
* @param condition the test condition.
*/
public static void assertTrue(String message, boolean condition) {
if (! condition) {
stdErr.print("** Test failure ");
stdErr.println(message);
}
}
}