SSD3-Quiz5

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);
        }
    }
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值