Chess Rating

<< DroppingLetters | OtherProjectsTrailIndex | Open House Password >>

Make a Player and a Match class to make this tester class work.

The Player class need to maintain the player's name and chess rating. It will nee accessor methods for both instance fields.

The Match class will keep track of the two players competing. It will have methods to add ties and wins, and report the score, and well as assign the new chess ratings to the chess players.

See this for the formula. A player with a rating of 1600 plays in an eleven-round tournament and scores 2½–8½ (22.7%) against competition with an average rating of 1850. This is 27.3% below 50%, so their new rating is 1850 – (10 × 27.3) = 1577

public class ChessRatingTester {

	/**
	 * @param args
	 * see http://en.wikipedia.org/wiki/Harkness_rating_system#Harkness_system
	 */
	public static void main(String[] args) {
		Player bob = new Player("Bob", 1600);
		Player bill = new Player("Bill", 1800);
		Match usa = new Match (bob, bill);
		usa.addTie();
		usa.addTie();
		usa.addTie();
		usa.addWin(bob);
		usa.addWin(bob);
		usa.addWin(bob);
		usa.addWin(bob);
		usa.addWin(bob);
		usa.addWin(bob);
		usa.addWin(bob);
		usa.addWin(bill);
        System.out.println(usa.score()+"--Expected bill 2.5, bob 8.5");
        usa.setNewRating(bill);
        System.out.println(bill.getRating()+"--Expected 1577");      
	}

}