CPSC 120 -- Assignment #2: Bocce
Due Friday, October 15, 2010 by 4 p.m.

Write a program that simulates bocce, an Italian bowling game. The game is played by two teams rolling palm sized balls towards a smaller ball, called the jack. The points of a round of bocce are calculated after both teams roll all of their balls. The team with the ball closest to the jack gets one point for each ball that is closer than the closest ball of the opposing team. The above image shows the team with red balls getting one point because it only has one red ball closer to the yellow ball, the jack, then the blue team.

Begin by creating a java file with the appropriate classes and methods to create and display a window. The window should contain a drawing of the jack and four balls, two for each team, as illustrated in the image above. The jack should be centered in the window and the location of the four balls should be randomly generated. It is ok if the balls overlap, but they should not exceed the window dimensions. Finally, calculate and draw how many points were scored and by which team. To calculate the score you must calculate the distance between each ball and the jack. This involves calculating the distance from the center of the jack to the center of each ball. You can calculate this using the usual distance formula (which comes from the Pythagorean theorem):

√((x2-x1)2+(y2-y 1)2)

Requirements:

Warning: A program that does not compile will receive at most 20% on the assignment even if the error is a small one preventing compilation.

Submission

From your assn2 directory, tar your code using the command:

   tar czf yournameAssn2.tgz .

To submit your code, copy the tar file containing your code to the directory:

   ~ingram/CPSC120/yourname

Academic Integrity Reminder!!! Programming assignments are to be your own work. You may get help on the specifics of the assignment from no one except the instructor. You may not show your program to anyone or look at anyone else's program or share ideas with anyone about how to write the program.