In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to achieve simple backgammon in java". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to realize simple backgammon game with java".
Use of the JOptionPane class
Write programs to achieve a simple game of backgammon. In backgammon, the two sides take turns playing chess on a 3 × 3 chessboard, one side is shown by * and the other side is represented by O. If three pieces of a side occupy the same row, column or diagonal, that side wins. If the chessboard is full of pieces, but no one wins, there will be a draw. In the program, one side is the user, and the user enters the position of each chess game on the interface; the position of the other side playing chess is randomly and automatically generated. The sample interface is shown in the figure.
Tip: (1) use the method input provided in the Scanner class or the JOptionPane class, and the output use the method in the System.out or the method provided by the JOptionPane class. (2) String or StringBuffer classes can be used for string processing.
Implementation code:
Import java.util.Random;import javax.swing.*;public class Main {public static boolean check (StringBuffer st,int pos) {/ / check whether the pieces on the pos win or not char des=st.charAt (pos); char [] s=new char [10]; for (int iTunes 1)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.