Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java编程,在数组中查找键的连接 /* *要更改此许可证标题,请在“项目属性”中选择“许可证标题”。 *要更改此模板文件,请选择工具|模板 *然后在编辑器中打开模板。 */ 包装w01s03p; 导入静态java.sql.Types.NULL; 导入ja_Java_Arrays_Search - Fatal编程技术网

Java编程,在数组中查找键的连接 /* *要更改此许可证标题,请在“项目属性”中选择“许可证标题”。 *要更改此模板文件,请选择工具|模板 *然后在编辑器中打开模板。 */ 包装w01s03p; 导入静态java.sql.Types.NULL; 导入ja

Java编程,在数组中查找键的连接 /* *要更改此许可证标题,请在“项目属性”中选择“许可证标题”。 *要更改此模板文件,请选择工具|模板 *然后在编辑器中打开模板。 */ 包装w01s03p; 导入静态java.sql.Types.NULL; 导入ja,java,arrays,search,Java,Arrays,Search,Java编程,在数组中查找键的连接 /* *要更改此许可证标题,请在“项目属性”中选择“许可证标题”。 *要更改此模板文件,请选择工具|模板 *然后在编辑器中打开模板。 */ 包装w01s03p; 导入静态java.sql.Types.NULL; 导入java.util.Scanner; /** * *@author WIN8 */ 公开课任务5{ 私有静态整数级; 私有静态int攻击级别; 私有静态int-def级别; 私有静态int级; 私有静态数据; 私有静态字符串[]arrName; 专

Java编程,在数组中查找键的连接
/*
*要更改此许可证标题,请在“项目属性”中选择“许可证标题”。
*要更改此模板文件,请选择工具|模板
*然后在编辑器中打开模板。
*/
包装w01s03p;
导入静态java.sql.Types.NULL;
导入java.util.Scanner;
/**
*
*@author WIN8
*/
公开课任务5{
私有静态整数级;
私有静态int攻击级别;
私有静态int-def级别;
私有静态int级;
私有静态数据;
私有静态字符串[]arrName;
专用静态int数据计数器;
计数器的私有静态int数据;
私有静态int输入选择;
专用静态双温;
公共静态void main(字符串[]\u参数){
int numberOfData=3;
int i,温度=0;
输入选择;
//声明
字符串[]名称;
双[]arrHP;
双[]arrAP;
双[]arrDP;
双水平;
双[]攻击级别;
双水平;
双[]级;
//实例化
arrName=新字符串[numberOfData];
arrHP=新的双精度[numberOfData];
arrAP=新的双精度[numberOfData];
arrDP=新的双精度[numberOfData];
hitLevel=新的双精度[numberOfData];
attackLevel=新的双精度[numberOfData];
defLevel=新的双精度[numberOfData];
级别=新的双精度[numberOfData];
做{
扫描仪=新的扫描仪(System.in);
System.out.println(“------------------”);
System.out.println(“Monsville锦标赛”);
System.out.println(“------------------”);
System.out.println(“1.List Monster”);
System.out.println(“2.Best By Hits Point”);
System.out.println(“3.Best By Attack Point”);
System.out.println(“4.Best By Defense Attack”);
System.out.println(“5.Search Profile”);
System.out.println(“6.0注册怪物”);
System.out.println(“0.Quit”);
inputChoice=Keyin.inInt(“您的选择:”);
开关(输入选择){
案例1:
System.out.println(“列表怪物:”);
if(arrName==null){
System.out.println(“输入怪物”);
}否则{
对于(i=0;i<2;i++){
System.out.println(“怪物名称”+arrName[i]);
}
}
打破
案例2:
System.out.println(“Daftar最佳HP!”);
如果(arrHP!=null){
对于(i=0;i<2;i++){
if(arrHP[i]=100){
hitLevel[i]=3;
}否则如果((arrHP[i]>=50)和&(arrHP[i]<100)){
hitLevel[i]=2;
}否则如果(arrHP[i]<50){
hitLevel[i]=1;
}
}
对于(i=0;i<2;i++){
如果(arrAP[i]>=20){
攻击级别[i]=3;
}else如果((arrAP[i]>=10)和&(arrAP[i]<20)){
攻击级别[i]=2;
}else if(arrAP[i]<10){
攻击级别[i]=1;
}
}
对于(i=0;i<2;i++){
如果(arrDP[i]>=15){
defLevel[i]=3;
}如果((arrDP[i]>=5)和&(arrAP[i]<15)){
defLevel[i]=2;
}否则如果(arrDP[i]<5){
defLevel[i]=1;
}
}
对于(i=0;i<2;i++){
等级[i]=+命中等级[i]+攻击等级[i]+解除等级[i];
}
系统退出。
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package w01s03p;

import static java.sql.Types.NULL;
import java.util.Scanner;

/**
 *
 * @author WIN8
 */
public class task5 {

    private static int hitLevel;
    private static int attackLevel;
    private static int defLevel;
    private static int LEVEL;
    private static int numberOfData;
    private static String[] arrName;
    private static int dataCounter;
    private static int dataOfCounter;
    private static int inputChoice;
    private static double temp;

    public static void main(String[] _args) {

        int numberOfData = 3;
        int i, temp = 0;
        int inputChoice;
//declaration
        String[] arrName;
        double[] arrHP;
        double[] arrAP;
        double[] arrDP;
        double[] hitLevel;
        double[] attackLevel;
        double[] defLevel;
        double[] LEVEL;

        //instantiation
        arrName = new String[numberOfData];
        arrHP = new double[numberOfData];
        arrAP = new double[numberOfData];
        arrDP = new double[numberOfData];
        hitLevel = new double[numberOfData];
        attackLevel = new double[numberOfData];
        defLevel = new double[numberOfData];
        LEVEL = new double[numberOfData];

        do {
            Scanner scanner = new Scanner(System.in);
            System.out.println("--------------------");
            System.out.println("Monsville Tournament");
            System.out.println("--------------------");
            System.out.println("1.List Monster");
            System.out.println("2.Best By Hits Point");
            System.out.println("3.Best By Attack Point");
            System.out.println("4.Best By Defense Attack");
            System.out.println("5.Search Profile");
            System.out.println("6.Registration Monster");
            System.out.println("0.Quit");
            inputChoice = Keyin.inInt(" Your Choice: ");
            switch (inputChoice) {
                case 1:
                    System.out.println("List Monster : ");
                    if (arrName == null) {
                        System.out.println("Input Monster");
                    } else {
                        for (i = 0; i < 2; i++) {
                            System.out.println("Monster Name " + arrName[i]);
                        }
                    }
                    break;
                case 2:
                    System.out.println("Daftar Best HP!");
                    if(arrHP != null){
                    for (i = 0; i < 2; i++) {
                        if (arrHP[i] < arrHP[i + 1]) {
                            temp = (int) arrHP[i + 1];
                            arrHP[i + 1] = arrHP[i];
                            arrHP[i] = temp;
                        }
                        System.out.println("HP (" + arrHP[i] + ")    :" + arrName[i]);
                    }
                    }
                    break;
                case 3:
                    System.out.println("Daftar Best AP!");
                    for (i = 0; i < 2; i++) {
                        if (arrAP[i] < arrAP[i + 1]) {
                            temp = (int) arrAP[i + 1];
                            arrAP[i + 1] = arrAP[i];
                            arrAP[i] = temp;
                        }
                        System.out.println("AP (" + arrAP[i] + ")    :" + arrName[i]);
                    }
                    break;
                case 4:
                    System.out.println("Daftar Best DP!");
                    for (i = 0; i < 2; i++) {
                        if (arrDP[i] < arrDP[i + 1]) {
                            temp = (int) arrDP[i + 1];
                            arrDP[i + 1] = arrDP[i];
                            arrDP[i] = temp;
                        }
                        System.out.println("DP (" + arrDP[i] + ")    :" + arrName[i]);
                    }
                    break;
                case 5:
                    System.out.println("Search Profile Monster");
                    break;
                case 6:
                    for (i = 0; i < 2; i++) {
                        System.out.print("Monster Name: ");
                        arrName[i] = scanner.next();
                        System.out.print("hit point: ");
                        arrHP[i] = scanner.nextInt();
                        System.out.print("attack point: ");
                        arrAP[i] = scanner.nextInt();
                        System.out.print("defense point: ");
                        arrDP[i] = scanner.nextInt();
                    }
                    break;
                default:
                    System.out.println("Invalid selection");
                    break;
            }
        } while (inputChoice != 0);

        for (i = 0; i < 2; i++) {
            if (arrHP[i] >= 100) {
                hitLevel[i] = 3;
            } else if ((arrHP[i] >= 50) && (arrHP[i] < 100)) {
                hitLevel[i] = 2;
            } else if (arrHP[i] < 50) {
                hitLevel[i] = 1;
            }
        }
        for (i = 0; i < 2; i++) {
            if (arrAP[i] >= 20) {
                attackLevel[i] = 3;
            } else if ((arrAP[i] >= 10) && (arrAP[i] < 20)) {
                attackLevel[i] = 2;
            } else if (arrAP[i] < 10) {
                attackLevel[i] = 1;
            }
        }
        for (i = 0; i < 2; i++) {
            if (arrDP[i] >= 15) {
                defLevel[i] = 3;
            } else if ((arrDP[i] >= 5) && (arrAP[i] < 15)) {
                defLevel[i] = 2;
            } else if (arrDP[i] < 5) {
                defLevel[i] = 1;
            }
        }

        for (i = 0; i < 2; i++) {
            LEVEL[i] = +hitLevel[i] + attackLevel[i] + defLevel[i];
        }

        System.out.println("---------monster profile ---------\"");

        for (i = 0; i < 2; i++) {
            System.out.println("name         : \"" + arrName[i] + "\"");
            System.out.println("hit point    :" + arrHP[i]);
            System.out.println("attack point :" + arrAP[i]);
            System.out.println("defense point:" + arrDP[i]);
            System.out.println("level        :" + LEVEL[i] + "(" + arrHP[i] + "/" + arrAP[i] + "/" + arrDP[i] + ")");
        }

    }

}
String searchQuery = scanner.next();
int indexFound = -1;
for(int x = 0; x < arrName.length; x++) {
    if(arrName[x] != null && (arrName[x].toLowerCase().equals(searchQuery.toLowerCase()) || arrName[x].toLowerCase().contains(searchQuery.toLowerCase())) {
        indexFound = x;
        break;
    }
}

if(indexFound != -1) {
    System.out.println("Monster Found by the name of " + searchQuery)
    System.out.println("name         : \"" + arrName[indexFound] + "\"");
    System.out.println("hit point    :" + arrHP[indexFound]);
    System.out.println("attack point :" + arrAP[indexFound]);
    System.out.println("defense point:" + arrDP[indexFound]);
    System.out.println("level        :" + LEVEL[indexFound] + "(" + arrHP[indexFound] + "/" + arrAP[indexFound] + "/" + arrDP[indexFound] + ")");
} else {
    System.out.println("Monster not found");
}