码迷,mamicode.com
首页 > Web开发 > 详细

简简版攻击网站游戏的设计

时间:2016-09-23 16:38:14      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

游戏介绍,我们把网站命名为DotCom,将它放在一个横列中的3个格子里,玩家输入位置来猜测网站被存放的位置,猜中为hit,如果三个格子都猜中为kill,没有猜中为miss。

在简简版中我们把这些都固定。

 1 public class SimpleDotCom {
 2    int[] locationCells;
 3    int numOfHits = 0;
 4 
 5 public void setLocationCells(int[] locs){
 6    int guess = Integer.parseInt(StringGuess);
 7    String result = "miss";
 8    for (int cell : locationCells) {
 9         if (guess == cell) {
10            result = "hit";
11            numOfHits++;
12            break;
13      }
14 }
15   if(numOfHits ==locationCells.length){
16      result = "kill"; 
17     } 
18   System.out.println(result);
19        return result;
20    }   
21 }

public class SimpleDotComTestDrive{
   public static void main (String [] args){
       SimpleDocCom dot = new SimpleDotCom();
       int[] locations = {2,3,4};
       dot.setLocationCells(locations);
       String uerGuess = "2";
       String result = dot.checkYourself(userGuess);  
       }
}

 

简简版攻击网站游戏的设计

标签:

原文地址:http://www.cnblogs.com/xwzp/p/5900401.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!