import java.util.Scanner;
import t7.SimpleDotCom;
/*题目描述:(战舰游戏二)有一种棋牌类的战舰游戏,目标是要猜测对方战舰的坐标,然后轮流开炮攻击,命中数发就可以打沉对方的战舰。现在我们先在做一个简单的战舰游戏
首先创建一个SimpleDotCom类,需要一个记录战舰位置的locationCells数组和一个记录击沉战舰数量的numOfHits成员变量;
创建一个获取主函数中输入发射位置的方法setLocationCells;
然后创建一个用于判断是否击中checkYourself的方法,在checkYourself方法中创建一个Sting类型的result局部变量,初始化result的值为"miss",
如果命中一个则为hit;如果全部命中完毕则为Kill;
输入一共有四行,第一行为战舰的数量
第二行为战舰的位置
第三行为用户攻击的次数
第四行为用户攻击的位置
输出为一个字符串(判断是否击沉)
/
/*测试输入:3
1 2 3
2
1 2 3
测试输出:Kill
/
主程序如下,请输出子程序
public class DotComTester {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner num = new Scanner(System.in);
int n;
n = num.nextInt();
int[] locations = new int[n];
for(int i=0;i<n;i++){
locations[i] = num.nextInt();
}
DotCom dot = new DotCom();
dot.setLocationCells(locations);
int m;
m = num.nextInt();
int[] userGuess = new int[m];
for(int i=0;i<m;i++){
userGuess[i] = num.nextInt();
}
String result = dot.checkYourself(userGuess);
}
}
/*测试数据:
1 2 3
3
1 2 3
1 2 3
2
1 2
1 2 3
3
4 5 6
所以你这个啥问题