我遇到了问题,我在Eclipse中收到了"死代码"警告,我真的不知道为什么.代码来自我的Connect Four项目,更确切地说,它来自Class,它检查是否有人获胜.此方法检查红色的所有水平获胜可能性.代码如下:
/**
* Method to check the horizontal winning possibilities for red
* @return true if red won or false if not
*/
public boolean checkHorRed(){
for(int line = 0; line < 6; line++) {
for(int column = 0; column < 4; column++) { //column++ is underlined and causes the "dead Code" warning
if(gw.buttons[line][column].getIcon().equals(gw.red));
if(gw.buttons[line][column+1].getIcon().equals(gw.red));
if(gw.buttons[line][column+2].getIcon().equals(gw.red));
if(gw.buttons[line][column+3].getIcon().equals(gw.red));
return true;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
由于这种方法,甚至可以立即赢得比赛.这有点奇怪的是,类中看起来几乎相同的所有其他方法都不会导致任何问题.以下是检查黄色垂直获胜可能性的方法,以进行比较:
/**
* Method to check the vertical winning possibilities for yellow
* @return true …Run Code Online (Sandbox Code Playgroud)
我目前正在开发HTML和CSS项目.它需要某种导航菜单,我已经创建了它.单击按钮时菜单会打开,它应该从左侧滑入.现在我的问题是过渡不起作用,我不明白为什么.这是我第一次使用CSS过渡.
这是jsfiddle:http: //jsfiddle.net/Lunaetic/tonqr3gx/(按钮的图像无法在那里显示并不重要)
这里的代码:
HTML
<div class="collapsibleList">
<label for="box1"><img src="TOPBAR_Icon_Home.png" alt="Menu icon"/></label>
<input type="checkbox" id="box1" />
<ul class="menu">
<li></li>
<li>Menu item 1</li>
<li>Menu item 2</li>
<li>Menu item 3</li>
<li>Menu item 4</li>
<li>Menu item 5</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.menu{
list-style-type: none;
position: fixed;
top: -16px;
left: -300px;
max-width: 300px;
transition: left 1s ease;
-webkit-transition: left .5s ease;
}
.menu li {
font-family: Arial;
font-size: 1.5em;
font-weight: bold;
padding: 10px;
background-color: #ffd012;
color: #000000;
border-bottom: 1px solid #ffffff;
padding-left: …Run Code Online (Sandbox Code Playgroud)