英文:
java word game logic
问题
if(长度大于3){
if(在单词库中){
if(以前一个单词的最后两个字母开头){
currentPlayerPoints+=1;
message="答对了,你得到了一分";
}else{
currentPlayerLives-=0;
message="你没有匹配上单词";
}
}else{
message="你的单词不在数据库中";
currentPlayerLives-=0;
}
}else{
message="你的单词至少应该有3个字母";
currentPlayerLives-=0;
}
英文:
Hi I have to create a game for two players where one player guesses the word starting on random char , min 3 letters long and should be in word base, the second player word should meet last 2 conditions plus should start on two last letters of the word provided by first player. Both players start with 3 lives. Example:
random word:e
firstPlayer:echo
secondPlayer:hollow
Do you think that using multiple nested if statements will be fine? How to add random char at first attempt?
if(longer than 3){
if(in word base){
if(starting with 2 letters from previous last letters){
currentPlayerPoints+=1;
message="Thats right you got a point";
}else{
currentPlayerLives-=0;
message="you didnt match the word";
}
}else{
message="your word is not in database";
currentPlayerLives-=0;
}
}else{
message="your word should be longer at least 3 letters long";
currentPlayerLives-=0;
}
专注分享java语言的经验与见解,让所有开发者获益!
评论