terminating a game of battleship

7 次查看(过去 30 天)
James Webber
James Webber 2022-1-6
评论: Voss 2022-1-6
i am writting the gaem battleship and i was wondering how to write a section of code so that if you type the word 'quit' in the command window it terminates the whole program no matter what stage it is at,
i have tried this -
if quit
disp ('end game')
end
but it does not work and is showing errors when i try ot use it
  1 个评论
Voss
Voss 2022-1-6
quit = strcmp(input('Quit?','s'),'quit');
if quit
disp ('end game')
% terminate the game somehow
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Number games 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by