Crossword puzzles (Basic Framework)

Source: Internet
Author: User

My wife is fond of playing crossword puzzles. For example, she is always fond of chatting about the weekly issue of "Xiaoqiang crossword" in southern China. Recently, I have nothing to worry about. I may wish to fill in the text on my computer and smile with my wife ^-^.
Should there be a tpuzzleitem class first? This represents a single item of the puzzle, including coordinates, directions (horizontal or vertical), hidden faces, and answers. By the way, the answers entered by the problem-solving personnel should also be saved. This tpuzzleitem should also have some methods (classes without methods are unnecessary ), it is important to return the characters of the Cell Based on the given logical coordinates (if the given coordinates do not belong to the entry, null is returned). To facilitate import and export, there should also be exporttoxmlnode and importfromxmlnode methods to facilitate Import and Export based on XML nodes.
Multiple entries should be managed by the tpuzzle class. tpuzzle has a private tlist object to maintain the list of entries, instead of inheriting tpuzzle from the tcollection, because I really don't want to know much about the internal structure of the tcollection, using delegation instead of inheritance is also a consistent practice. Similarly, tpuzzle should also have the exporttoxmlnode and importfromxmlnode methods. Each tpuzzle represents a puzzle. to distinguish different puzzles, it has a guid attribute.
Tpuzzle has nothing to do with tpuzzleitem in GUI. It only provides the logic of the Puzzle. As for how to implement it on the interface and how to interact with the user, it is handed over to tpuzzlegui for processing. Tpuzzlegui delegates a private field fpuzzle to handle logic issues and accepts user input and is responsible for drawing puzzles on the screen. Tpuzzlegui inherits from tcustomcontrol and has the ws_vscrollbar and ws_hscrollbar attributes, so that a large grid is displayed to the user (although it can not be used). Because no two-dimensional array is created for the grid, tpuzzle is used to maintain a list of entries. Therefore, the occupied memory does not increase because of the number of grids displayed on the screen.
The design of the interface can be simplified and complex. Everything is drawn out. Because there are many small areas to draw, tpuzzlegui also uses a buffer zone to first draw all the content to be drawn in the buffer zone, painting the screen at one time is a bit like DirectDraw, but this kind of gadgets don't have to work on DX's big drive. The interface design is slightly more subtle, and it gives users a better feeling. Unfortunately, it is not a good artist and there is no way to make everything so perfect :-(
There is still a question about how to save multiple puzzles. This storage is completed by tpuzzlecontainer. This is an abstract class that can help you change the storage mode in the future. For example, you can use XML for storage today, I figured it out tomorrow. Maybe I will use an Access database. Abstract Factory models should be used. Although there is no benefit to them.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.