danialgifani
یک شنبه 16 فروردین 1388, 10:38 صبح
Title: Who will marry the princess?
Description
A beautiful princess is to select a husband from n suitors. The suitors are assigned numbers 0, 1, 2, …, n-1 and seated at a round table. A random sequence of n-1 numbers x0, x1, …, xn-2, all of them in the range 0 until n-1 is selected. The princess starts at suitor 0, and moving in a clockwise direction. She counts off x0 positions and eliminates the suitor at that position. From there, she counts off another x1 positions (the next number in the random sequence) and eliminates the suitor at that position. She continues doing this until one lucky guy is left: she marries him and they live happily ever after.
As an example, assume the suitors are A, B, C, and D, with A being numbered 0 and D being numbered 3. Let the random sequence be 0, 2, 1. Then the suitors will be eliminated in the order A, D, and C, and the lucky suitor will be B.
Write a Java program that helps the princess make her decision. The program stores the suitors’ names in a text file. It also allows the princess to add a suitor to the file, update a suitor’s name, and delete a suitor or the entire list of names in the file. The princess will select some or all of the suitors on the list to be her candidates.
The princess can then enter a number (x0) for the rotation step. The number can be generated randomly by the program as well. The program displays a list of suitors already eliminated/rejected and another list of suitors still under consideration. The princess enters the next rotation number (x1), or let the system generates the number randomly. The elimination process continues and the program displays both “rejected” and “under consideration” lists. These steps are repeated until there is only one suitor left in the “under consideration” list.
You need to:
(a) Design an algorithm (presented as flow chart) that describes the selection process.
(b) Present the classes designed using UML class diagrams.
(c) Use appropriate GUI (Graphical User Interface) elements to make your program easy to use and displays its output in a clear and comprehensive manner.
Submission:
A CD/diskette containing the executable project file, and the source codes.
A report explaining the problem, requirements of the project, program design (the algorithm and classes), the data structure(s) used, and sample output screens. Include the contribution evaluation form in the report.
Due date: 12.00pm on Friday 3 April 2009.
Marking Scheme (20%)
1. Source code/Program. (14%)
a. Meeting system requirements – 6%
b. Application of data structures and programming techniques – 5%
c. Programming styles and convention – 1%
d. Bug-free – 2%.
2. Report (6%):
a. System analysis and design – 4%.
b. Presentation of program output – 2%
3. Marks will be deducted for the following:
a. 2 marks for each day of delay in submission.
Description
A beautiful princess is to select a husband from n suitors. The suitors are assigned numbers 0, 1, 2, …, n-1 and seated at a round table. A random sequence of n-1 numbers x0, x1, …, xn-2, all of them in the range 0 until n-1 is selected. The princess starts at suitor 0, and moving in a clockwise direction. She counts off x0 positions and eliminates the suitor at that position. From there, she counts off another x1 positions (the next number in the random sequence) and eliminates the suitor at that position. She continues doing this until one lucky guy is left: she marries him and they live happily ever after.
As an example, assume the suitors are A, B, C, and D, with A being numbered 0 and D being numbered 3. Let the random sequence be 0, 2, 1. Then the suitors will be eliminated in the order A, D, and C, and the lucky suitor will be B.
Write a Java program that helps the princess make her decision. The program stores the suitors’ names in a text file. It also allows the princess to add a suitor to the file, update a suitor’s name, and delete a suitor or the entire list of names in the file. The princess will select some or all of the suitors on the list to be her candidates.
The princess can then enter a number (x0) for the rotation step. The number can be generated randomly by the program as well. The program displays a list of suitors already eliminated/rejected and another list of suitors still under consideration. The princess enters the next rotation number (x1), or let the system generates the number randomly. The elimination process continues and the program displays both “rejected” and “under consideration” lists. These steps are repeated until there is only one suitor left in the “under consideration” list.
You need to:
(a) Design an algorithm (presented as flow chart) that describes the selection process.
(b) Present the classes designed using UML class diagrams.
(c) Use appropriate GUI (Graphical User Interface) elements to make your program easy to use and displays its output in a clear and comprehensive manner.
Submission:
A CD/diskette containing the executable project file, and the source codes.
A report explaining the problem, requirements of the project, program design (the algorithm and classes), the data structure(s) used, and sample output screens. Include the contribution evaluation form in the report.
Due date: 12.00pm on Friday 3 April 2009.
Marking Scheme (20%)
1. Source code/Program. (14%)
a. Meeting system requirements – 6%
b. Application of data structures and programming techniques – 5%
c. Programming styles and convention – 1%
d. Bug-free – 2%.
2. Report (6%):
a. System analysis and design – 4%.
b. Presentation of program output – 2%
3. Marks will be deducted for the following:
a. 2 marks for each day of delay in submission.