gpt4 book ai didi

java - 我不断收到 ']' 预期错误 [Java]

转载 作者:行者123 更新时间:2023-11-29 04:35:33 24 4
gpt4 key购买 nike

<分区>

出于某种原因,eclipse 一直在 npcname_m[0]="steve"; 给我一个 ']' 错误;

    String npcname_m[]=new String[10];
npcname_m[0]="Steve";
npcname_m[1]="John";
npcname_m[2]="Mark";
npcname_m[3]="Andrew";
npcname_m[4]="Matthew";
npcname_m[5]="Luke";
npcname_m[6]="Miguel";
npcname_m[7]="Michael";
npcname_m[8]="Josh";
npcname_m[9]="Alex";

完整代码

public class npc
{
//NPC Types; Speci
public enum npctype{villager, mob, special, hostile, passive, placeholder}
npctype npc_type =npctype.placeholder;
String npcname_m[]=new String[10];
npcname_m[0]="Steve";
npcname_m[1]="John";
npcname_m[2]="Mark";
npcname_m[3]="Andrew";
npcname_m[4]="Matthew";
npcname_m[5]="Luke";
npcname_m[6]="Miguel";
npcname_m[7]="Michael";
npcname_m[8]="Josh";
npcname_m[9]="Alex";

String[] npcname_f = new String[10];
npcname_f[0]="Mariah";
npcname_f[1]="Joyce";
npcname_f[2]="Kaede Akamatsu";
npcname_f[3]="Iruma Miu";
npcname_f[4]="Maki";
npcname_f[5]="Hannah";
npcname_f[6]="Angie";
npcname_f[7]="Grace";
npcname_f[8]="Melissa";
npcname_f[9]="Alex";

public enum npcclass{weak, strong, rare}
String name = "Placeholder to avoid problems with garbage collector";
int healthpoints =100;
int moneyreward =100;
int attackpower=100;
Boolean male = true;

//code to attack player if player starts dsplaying aggressive behaviour torward friendly NPC's
//Placeholder code
public void AttackHostilePlayer(){
return;
}

public void TransformHostileVillager(){
healthpoints= healthpoints + 50;
attackpower=attackpower + 50;
System.out.println(npc_type);
return;
}

//Generates an npc (Add randomisation later)
public void generatenpc(){
male = true;
name= "Steve";
npc_type=npctype.villager;
return;
}
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com