Java from basic to advanced learning-how to create a Sudoku game (1)

Source: Internet
Author: User

Java from basic to advanced learning-how to create a Sudoku game (1)
Preface

Most people have played this game, so the specific game itself is not described.

 

Rules and objectives

The rule of DT independence is simple, that is, duplicate numbers cannot appear in each row, column, and cell (3X3.

First, paste the approximate game interface:

Requirement Function Analysis

From the perspective of learners

Learn about the MVC Framework

The main Java content involved in this project is:

1. Basic Java syntax, especially the Java set.

2. Java built-in Observer mode.

3. Java AWT and Swing Components

4. Java component layout and event model Programming

From the player's perspective

Currently, only the most basic functions are implemented.

1) you can create a new game map and click the new button.

2) error: indicates whether the number in the current game progress does not comply with the rules is entered.

As follows:

3) Game assistance

That is, to enable the help function, click the corresponding number, and a prompt is displayed on the map where the number can be entered.

As follows:

 

4) the game is over, prompting whether to continue the game

5) quit

Summary Design Analysis

Now that we have learned about wiki MVC, we use the MVC framework for this project.

Therefore, we need to divide the sudoku game into three parts: model, view, and controller.

First, briefly describe the functions of each part of MVC: (the content comes from WIKI. For details, refer to the wiki link)

 

Model)It is used to encapsulate data related to the application's business logic and to process the data. The "model" has the right to directly access data, such as accessing databases. "Model" does not depend on "View" and "controller", that is, the model does not care about how it is displayed or operated. However, data changes in the model are generally published through a refresh mechanism. To implement this mechanism, the views used to monitor this model must be registered on this model in advance, so that the views can understand the changes in the data model. (Comparison: Observer mode (software design mode )) View)Data can be displayed purposefully (theoretically, this is not necessary ). Generally, there is no program logic in the view. To refresh a view, the view needs to access the data Model it monitors. Therefore, you should register the data that it monitors in advance. Controller)It serves as an organizational unit at different levels and is used to control application processes. It processes events and responds. "Events" include user behaviors and changes in data models.

 

The frame chart is as follows:

Model Section

1) Game MAP Storage Data Structure

2) New map generation algorithm of the game

3) check, help, and other functional Algorithms

Controller

1) Option Button and number selection response action

2) the corresponding number is entered.

View

1) Option Button, Help button, and number group button

2) enter the number and display it

4) Listener

 

In this example, the Observer mode is used to assist in data independence update checks and other operations.

 

OK. That's all about this section.

NEXT

Detailed design, including class diagrams, methods, and algorithms.

 

 

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.