Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Boxing King Mini Program by Java

Shulou Source: shulou.com Published: 2022-05-31 21:49:38 09月29日 Update

This article mainly introduces how Java to achieve Boxing King Mini Program related knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that everyone after reading this Java how to achieve Boxing King Mini Program article will have a harvest, let's take a look at it.

The code is as follows:

Package helloasd;import java.util.*;public class hellojava {public static void main (String [] args) {Scanner input = new Scanner (System.in); System.out.print ("enter name:"); / / enter the name String username = input.next () String comname = "Ajie"; System.out.println (username + "vs" + comname); / / initialize bilateral data int hp1 = 100, hp2 = 100; / / HP int attack1 = 0, attack2 = 0 / / use cycle to simulate the battle process while (hp1 > 0 & & hp2 > 0) {attack1 = (int) (Math.random () * 1000)% 11 + 5 / / the random attack power of both sides (1015) attack2 = (int) (Math.random () * 1000)% 11 + 5; / / players attack hp2-= attack1 first / / player attack, computer blood System.out.println (comname + ":" + hp2); if (attack1 > 0 & & attack1 5 & & attack1 0 & & attack1 5 & & attack1)

Tags: Boxing king program both sides players knowledge attack content article Ajie input code value name name simple operation attack power data article easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei Linux NVidia vpn