terminating a game of battleship

2 Ansichten (letzte 30 Tage)
James Webber
James Webber am 6 Jan. 2022
Kommentiert: Voss am 6 Jan. 2022
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 Kommentar
Voss
Voss am 6 Jan. 2022
quit = strcmp(input('Quit?','s'),'quit');
if quit
disp ('end game')
% terminate the game somehow
end

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Board games finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by