package helloasd;import java.util.*;
public
class
hellojava {
public
static
void main(String[] args) {
Scanner input =
new
Scanner(System.in);
System.out.
print
(
"输入名称: "
);
String username = input.next();
String comname =
"阿杰"
;
System.out.println(username +
"vs"
+ comname);
int hp1 = 100, hp2 = 100;
int attack1 = 0, attack2 = 0;
while
(hp1 > 0 && hp2 > 0) {
attack1 = (int)(Math.random() * 1000) % 11 + 5;
attack2 = (int)(Math.random() * 1000) % 11 + 5;
hp2 -= attack1;
System.out.println(comname +
": "
+ hp2);
if
(attack1 > 0 && attack1 <=5) {
System.out.println(
"阿杰被命中攻击!"
);
}
else
if
(attack1 > 5 && attack1 <=10) {
System.out.println(
"阿杰被重重的攻击!"
);
}
else
{
System.out.println(
"阿杰被致命一击!"
);
}
hp1 -= attack2;
System.out.println(username +
": "
+ hp2);
if
(attack1 > 0 && attack1 <=5) {
System.out.println(username +
"被"
+ comname +
"侥幸攻击了一下!"
);
}
else
if
(attack1 > 5 && attack1 <=10) {
System.out.println(username +
"遇到了强烈进攻!"
);
}
else
{
System.out.println(username +
"被沉重打击!"
);
}
System.out.println(
"\n"
);
}
System.out.println(
"\n"
);
System.out.println(
"KO!"
);
System.out.println(
"玩家姓名\t血量"
);
System.out.println(username +
"\t"
+ hp1);
System.out.println(comname +
"\t"
+ hp2);
if
(hp1 < 0) {
System.out.println(
"阿杰获胜!"
);
}
else
{
System.out.println(username +
"获胜!"
);
}
}
}