哪位可以帮我改改我的java程序, 自己编的一个游戏 但是无法运行。
packageHerosWorld;importjava.util.Scanner;publicclasshero{Stringname;intHP;intATT;int...
package HerosWorld;
import java.util.Scanner;
public class hero{
String name;
int HP;
int ATT;
int DEF;
public int attack( int DEF)
{
return ATT-DEF;
}
public void showme(){
System.out.println(name + "Attack:" + ATT +"Defensive:" + DEF + "Health:" + HP);
}
public class monster{
String name;
int HP;
int ATT;
int DEF;
public int attack( int DEF){
return ATT-DEF;
}
public void showme(){
System.out.println(name+"Attack:" + ATT +"Defensive:" + DEF + "Health:" + HP);
}
}
public class game{
int count;
hero h = new hero();
monster m = new monster();
Scanner input = new Scanner(System.in);
public void select(){
System.out.println("Please choose a hero");
System.out.println("1.Saber");
System.out.println("2.Archer");
System.out.println("3.Lancer");
System.out.println("4.Berserker");
System.out.println("5.Assassin");
System.out.println("6.God");
System.out.println("7.Loser");
int character = input.nextInt();
switch(character)
{
case 1: h.name = "Saber";
h.ATT = 70;
h.DEF = 89;
h.HP = 110;
break;
case 2: h.name = "Archer";
h.ATT = 100;
h.DEF = 69;
h.HP = 90;
break;
case 3: h.name = "Lancer";
h.ATT = 90;
h.DEF = 78;
h.HP = 95;
break;
case 4: h.name = "Berserker";
h.ATT = 89;
h.DEF = 89;
h.HP = 99;
break;
case 5: h.name = "Assassin";
h.ATT = 100;
h.DEF = 70;
h.HP = 90;
break;
case 6: h.name = " God";
h.ATT = 999999999;
h.DEF = 999999999;
h.HP = 999999999;
case 7: h.name = "Loser";
h.ATT = 1;
h.DEF = 1;
h.HP = 1000;
break;
}
h.showme();
}public void randomMonster(){
int rd =(int)(Math.random()*4+1);
switch(rd){
case 1: m.name = "Deathwing";
m.ATT = 99999;
m.DEF = 99999;
m.HP = 99999;
break;
case 2: m.name = "Grom Hellscream";
m.ATT = 88888;
m.DEF = 88888;
m.HP = 88888;
break;
case 3: m.name = "Leper gnomes";
m.ATT = 69;
m.DEF = 35;
m.HP = 60;
break;
case 4: m.name = "Troggs";
m.ATT = 40;
m.DEF = 70;
m.HP = 100;
break;
}
m.showme();
}
else{
m.showme();
int dH=m.attack(h.DEF);
if(dH<0){
dH=0;
}h.HP-=dH;
System.out.println(m.name + "You are under attack" + dH + "damage");
h.showme();
if(h.HP<0){
count++;
System.out.println("You got killed.");
return;
}}
if(h.HP > m.HP){
count++;
System.out.println("You killed" + m.name + "Continue(yes/no)");
String yes = input.next();
if(yes.equals("no")){
h.showme();
System.out.println("In all,You killed" + count + "Monsters");
return;
} } }
else{
System.out.println("You killed" + count + "Monsters");
}} }} 展开
import java.util.Scanner;
public class hero{
String name;
int HP;
int ATT;
int DEF;
public int attack( int DEF)
{
return ATT-DEF;
}
public void showme(){
System.out.println(name + "Attack:" + ATT +"Defensive:" + DEF + "Health:" + HP);
}
public class monster{
String name;
int HP;
int ATT;
int DEF;
public int attack( int DEF){
return ATT-DEF;
}
public void showme(){
System.out.println(name+"Attack:" + ATT +"Defensive:" + DEF + "Health:" + HP);
}
}
public class game{
int count;
hero h = new hero();
monster m = new monster();
Scanner input = new Scanner(System.in);
public void select(){
System.out.println("Please choose a hero");
System.out.println("1.Saber");
System.out.println("2.Archer");
System.out.println("3.Lancer");
System.out.println("4.Berserker");
System.out.println("5.Assassin");
System.out.println("6.God");
System.out.println("7.Loser");
int character = input.nextInt();
switch(character)
{
case 1: h.name = "Saber";
h.ATT = 70;
h.DEF = 89;
h.HP = 110;
break;
case 2: h.name = "Archer";
h.ATT = 100;
h.DEF = 69;
h.HP = 90;
break;
case 3: h.name = "Lancer";
h.ATT = 90;
h.DEF = 78;
h.HP = 95;
break;
case 4: h.name = "Berserker";
h.ATT = 89;
h.DEF = 89;
h.HP = 99;
break;
case 5: h.name = "Assassin";
h.ATT = 100;
h.DEF = 70;
h.HP = 90;
break;
case 6: h.name = " God";
h.ATT = 999999999;
h.DEF = 999999999;
h.HP = 999999999;
case 7: h.name = "Loser";
h.ATT = 1;
h.DEF = 1;
h.HP = 1000;
break;
}
h.showme();
}public void randomMonster(){
int rd =(int)(Math.random()*4+1);
switch(rd){
case 1: m.name = "Deathwing";
m.ATT = 99999;
m.DEF = 99999;
m.HP = 99999;
break;
case 2: m.name = "Grom Hellscream";
m.ATT = 88888;
m.DEF = 88888;
m.HP = 88888;
break;
case 3: m.name = "Leper gnomes";
m.ATT = 69;
m.DEF = 35;
m.HP = 60;
break;
case 4: m.name = "Troggs";
m.ATT = 40;
m.DEF = 70;
m.HP = 100;
break;
}
m.showme();
}
else{
m.showme();
int dH=m.attack(h.DEF);
if(dH<0){
dH=0;
}h.HP-=dH;
System.out.println(m.name + "You are under attack" + dH + "damage");
h.showme();
if(h.HP<0){
count++;
System.out.println("You got killed.");
return;
}}
if(h.HP > m.HP){
count++;
System.out.println("You killed" + m.name + "Continue(yes/no)");
String yes = input.next();
if(yes.equals("no")){
h.showme();
System.out.println("In all,You killed" + count + "Monsters");
return;
} } }
else{
System.out.println("You killed" + count + "Monsters");
}} }} 展开
3个回答
展开全部
少了caster和rider,没有集齐7人,圣杯战争无法开始
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-06-21
展开全部
这段代码是做什么的(需求是什么) 。。。。。。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主我看了一下你的代码,没有主函数main,还有很多地方的{}有问题,还有个地方没有if就出现了else。。。
http://yun.baidu.com/share/link?shareid=3631774133&uk=2721049345
这个是我改了一下以后的工程文件,你可以再改进。
http://yun.baidu.com/share/link?shareid=3631774133&uk=2721049345
这个是我改了一下以后的工程文件,你可以再改进。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询