Assignment 5 Programming part
Please check the blackboard for the writing assignment.
4 points + 5 extra points
Assigned: Thursday, July 12
Due: Thursday, July 19.
Demonstrate by yourself. Please demo it before the due date. After demonstration, send the source code to me through email.
Hints
a. The UML diagram of Player and Match Assignment5.ppt.
b. The method headers of Player.java and Match.java.
Description
The goal of this assignment is to become familiar with Object-Oriented Programming. For that, you will have to write a GUI-based program to record a basketball tournament.
Four college students come together to play one-to-one basketball tournament. They compete with each other to win the championship. There will be two semi-finals, a third-place match (contested by the losing semi-finalists), and a final. The program helps to record the evolution of the tournament.
The program will first ask the basic information of the four students. The basic information is the name and the college year of a student. The input format is: name collegeYear, e.g. John 2. The input dialog is shown as
below. If the input has correct format, the program will popup a message
dialog shown as below.
Then the program will ask the scores of each match. The format is: score1 score2, e.g. 45 67. The input dialog is shown as
below. If the input has correct format, the program will popup a message
dialog shown as below.
Based on the user input, the program will determine the championship. The final result is shown as
below.
We will implement the program using three classes: Player, Match, and Tournament. The
class tournament is already available. Part of the class Player is also available.
Requirement
a. Download the demo program: Tournament.java, Player.class and
Match.class to a same directory. Use jGrasp to open, compile
Tournament.java. Run Tournament.java
to understand the workflow of the program.
b. Read Tournament.java and Player.java. Figure out what methods should be provided by
Player.java and Match.java.
c. Add code to Player.java and implement Match.java. Add Player.java, Match.java and
Tournament.java to a same project. Make sure your implementation has the same functionality as the demo has.
Grading
[60%] Add code to Player.java and implement Match.java. Add Player.java, Match.java and
Tournament.java to a same project. Make sure your implementation has the same functionality as the demo has.
[30%] Handle the errors of the user input:
a) For the user information, an input string has two tokens: name collegeYear, e.g. John 2. Name must be a single token. The college year must be 1, or 2, or 3, or 4. The program will continue popup dialog until the correct format string is obtained.
b) For the match scores, an input string has two tokens: score1 score2, e.g. 45 67. score1 and score2 must be two positive integers. score1 cannot be equal to score2. The program will continue popup dialog until the correct format string is obtained.
[10%] Good style.
Algorithm description is not necessary.
5 Extra points
Implement the same workflow without using objects. The code should have the same functionality as the demo code has. Please refer to the slides 4, 5, 6 of the lecture 17-Jul_17.ppt.