| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1902 人关注过本帖
标题:[求助]help help assignment
取消只看楼主 加入收藏
Anstey
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2004-4-14
收藏
 问题点数:0 回复次数:2 
[求助]help help assignment

In one of the steps of the assignment, in says this: Write a method in the Board Class which is given a character c. The method should determine if any of the rows in the board contain a sequence of 4 or more of the given characters (e.g. if we have "connected four"). The method should return true if such a sequence exists in the board and false otherwise.

NOTE: The whole assignment is about creating a board , the getRow(int i) will return the index of i row as a String, and getSequence(char c,int i) is just return a String that contains i number of char c.

what I wrote didnt work, can any one tell me why???

public boolean isConnectedFour(char c){ boolean notStop = true; if(getRow(0).length()>=FOUR){ for(int i = 0; i<size && notStop; i++){ int index =getRow(i).indexOf(c); if(getRow(i).substring(index,index+4).equals(getSequence(c,FOUR))){ notStop = false; return true; } else return false;

}

} else return false;

}

搜索更多相关主题的帖子: assignment help 
2004-05-06 21:51
Anstey
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2004-4-14
收藏
得分:0 
Oh, I just forgot, FOUR is a static final variable. as public static final int FOUR = 4;

Anstey. Cheers. I love CAPPUCCINO~~
2004-05-06 21:53
Anstey
Rank: 1
等 级:新手上路
帖 子:94
专家分:0
注 册:2004-4-14
收藏
得分:0 

this is just getting strange, i dont know why that happens to my code when i put them in fourm, but anyway, i sovled that problem already

cheers.


Anstey. Cheers. I love CAPPUCCINO~~
2004-05-08 20:37
快速回复:[求助]help help assignment
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031321 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved