0
메신저로 스크립트를 만들어야하는데 카운터가 특정 숫자에 도달했을 때 단서를 표시하는 데 카운터를 추가하지 않는 것 같습니다Linux 스크립트 카운터가 올바르게 작동하지 않습니다.
#!/bin/bash
#This is a game that is played by the user having to guess a number that the computer thinks of.
counter=0
# functions
function clueOne() {
echo “The number is over 50”
return
}
function clueTwo() {
echo “The number is smaller than 100 and is devided by 7, 10 times”
return
}
function selectANumber() {
dialog --backtitle "Number Game" --title "Number Game" --infobox "Thinking of a number..."
10 50 ; clear
}
selectANumber
# game starts here
while [ $counter -le 10 ]; do
read -p ”Guess my number human!”
if [ $counter -eq 5 ];
then
clueOne
counter=$((counter+1))
elif [ $counter -eq 9 ];
then
clueTwo
counter=$((counter+1))
elif [ $REPLY = 70 ];
echo “Yes that is my number!”;
exit 1
echo “Wrong number”
counter=$((counter+1))
fi
done
echo “Sorry you ran out of attempts”
죄송합니다. 조금 새로운 것이지만, 정확히 어떻게할까요? –
신경 쓰지 마시고, 도와 줘서 고마워! –
도움이되었다고 생각하면 답변을 수락하여이 질문을 닫으십시오. – SMA