关于机器学习: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:

  1. A JPanel for the image block display
  2. A JTextArea for display message
  3. 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

【腾讯云】轻量 2核2G4M,首年65元

阿里云限时活动-云数据库 RDS MySQL  1核2G配置 1.88/月 速抢

本文由乐趣区整理发布,转载请注明出处,谢谢。

您可能还喜欢...

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据