Java from basic to Advanced learning----Sudoku Mini-game production (i)

Source: Internet
Author: User

Preface

Sudoku This game most people have played, so the specific game itself is not described.

See Baidu Encyclopedia: http://baike.baidu.com/subview/961/10842669.htm

Rules and Objectives

The rules of Sudoku are simple, that is, in each row, each column, each small Gongge area (3x3) can not appear duplicate numbers.

First paste the approximate game interface looks like:

Demand Function Analysis

From the learner's point of view,

Practice, learn the MVC framework pattern

The main content of Java involved in this project is:

1.Java basic syntax, especially in the Java Collections section.

2.Java built-in observer mode.

AWT and swing components for 3.Java

4.Java component layout and event model programming

Standing in the player's shoes

Currently only the most basic functions are realized.

1) You can generate a new game map, click the New button.

2) Wrong: That is, the current game progress, whether the number of non-compliance with the rules to fill in

As follows:


3) Game Assist

That is, to turn on the Help function, click on the corresponding number, will be on the map to indicate where the number can be filled.

As follows:


4) End of game, prompt whether to continue the game

5) Exit

Overview Design Analysis

Now that you're going to learn about wiki MVC, use the MVC framework to do this project.

So, it is necessary to divide the Sudoku game into three parts of Model,view,controller.

First, the function of the various parts of MVC is briefly described: (content from wiki, see wiki link)

    • model is used to encapsulate data that is relevant to the business logic of an application and how the data is processed. "Model" has the right to direct data access, such as access to the database. "Model" does not depend on "view" and "Controller", that is, the model does not care how it will be displayed or how it is manipulated. However, changes in the data in the model are generally advertised through a refresh mechanism. To implement this mechanism, the views that are used to monitor this model must be registered in advance on this model, so that the view can understand the changes that have occurred on the data model. (Comparison: Viewer mode (software design mode))
    • views enable the purposeful display of data (in theory, this is not required). There is generally no logic on the program in the view. To implement the Refresh feature on the view, the view needs to access the data model it monitors, so it should be registered with the data it is monitoring beforehand.
    • The controller acts as an organizational function between different levels to control the flow of the application. It handles the event and responds. An "event" includes the user's behavior and changes on the data model.

The frame diagram is as follows


Model Section

1) game map storage data structure

2) New map generation algorithm for games

3) Check,help and other functional algorithms

Controller section

1) Response Action for option button and number selection

2) Fill in the number of the action corresponding

View section

1) option button, help radio box, Number group button

2) digital fill in display

4) Listener


It uses the Observer mode to assist in the implementation of the Sudoku update check and other operations.


OK, here's what this section is all about.

NEXT

Detailed design, including class diagram, methods, algorithms and other implementations.



Java from basic to Advanced learning----Sudoku Mini-game production (i)

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.