dimanche 3 mai 2020

java word game logic

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;
}

Aucun commentaire:

Enregistrer un commentaire