COMP2396
Posted n6nzcewp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了COMP2396相关的知识,希望对你有一定的参考价值。
COMP2396
Due: 14 April, 2019, 23:55
Introduction
This assignmenttests your skills on writing simple JavaGUI program, using Java graphics and
events.
YouneedtowriteapuzzleprogramJavaPuzzle.java,whichallows theusertoselectan
image as a puzzle and the user can then play with the selected images.
This assignment will be evaluated on both functionality and program design. You can get
part ofthe full marks if you implement some ofthe features.
You are expected to use Java GUI graphics to display the userinterface ofthis assignment.
YouarealsorequiredtowriteJavaDocforallnon-privateclassesandnon-privateclass
members. Programs without JavaDoc will not be marked.
Part I Select an Image
WhenJavaPuzzleisexecuted,afilechoosershouldbepresentedtoaskforanimagefile.
Part II Display the Image and randomize the image
Theimageisloadedfromtheselectedfileandisdividedintoblocksof80*80pixelsin
size displayed as shown in above figure. The blocks ofthe image are randomized so that
the user will not see the original image.Ifthe image file fails to load,the program should
generateanerrormessageandasktheusertoselectanotherimagefile.Eachimage
blockshouldkeepitsoriginalpositioninformationsothattheoriginalimagecanbe
reconstructed.
Your main UI should contain the following:
- A JPanel for the image block display
- A JTextArea for display message
- Three JButtons:load image, show the original image and exit.
You are notrequired to follow exactly the size ofthe JTextArea and JButton objects as in
the the above figure, but should look similarto it.
The image should be resized and scaled to fitinto a canvas of 800*800 pixels in size.Ifthe
new image fails to load, an error message should be displayed and the old image is retained.
Part III Drag and Drop the image to the right position
The movements ofimage block are controlled manually by pressing and releasing the
mouse.If an image block is currently at(i,j),the user has to press the mouse at(i,j) and
drag itto the targetimage block position,then the selected image block and the target
image block will be swapped.
Note thatthe image block is notrequired to be with the cursor during dragging. Make sure it
causes a move when you release it at a proper position, and updates the image blocks in the
panel. After swapping,if any image block is placed on its original correct position, a message
should bedisplayed.
Ifthe destination image block is in the correct position, drag and drop anotherimage block
to that position will NOT swap their position, and a message should be displayed. The game
is finished when all image blocks are in correct position.
Marking
80% marks are given to the functionality.
l Youmay addadditional classes,instant variables and methods tothe project
l Youwill get part ofthe full marks if you implement some ofthe features.
l A program that can run normally withoutthrowing exceptions during runtime gets
higher marks.
20% marks are given to the program design.
l Youshould make good use ofinheritance,polymorphism,layout, painter and event
handler.
l You can check it by avoiding code duplication as much as possible.
l Economyisvaluableincoding:theeasiestwaytoensureabug-freelineofcodeisnot
to write the line of code at all.
Programs without JavaDoc will not be marked.
Programs with compilation error will not be marked.
Submission:
Please submit all source files (*.java)in a single compressed file (in .zip or.7z)to
Moodle. Do not submit .class file.
WX:codehelp
以上是关于COMP2396的主要内容,如果未能解决你的问题,请参考以下文章