How do i return to a menu box that i just came from?
1 回表示 (過去 30 日間)
古いコメントを表示
I am attempting to create a choose you own adventure scenario, but i do not know how to return to the previous menu box. This is what i have so far:
input=menu('Please pick what kind of characture you want to be.',...
'Hunter','Warrior','Mage','Demon','Elf');
switch input
case 1
hunter=menu('The Hunter is a characture that prefers to fight from a distance. Do you want the Hunter?','Yes','No');
switch hunter
case 1
disp('Congrates you have choosen the Hunter. Your jurney is about to begin.')
case 2
end
case 2
disp('The Warrior is a characture with a high strength.')
case 3
disp('The Mage is a Characture that attacks with magic from a distance.')
end
I would like the second case 2 to return me back to the first menu. any help would be appreciated.
0 件のコメント
採用された回答
Image Analyst
2013 年 3 月 19 日
編集済み: Image Analyst
2013 年 3 月 19 日
Wrap the whole thing in a while, and add break statements. Don't add a break if you want the code to repeat and ask the user again. That's one way anyway:
while true
input=menu('Please pick what kind of character you want to be.',...
'Hunter','Warrior','Mage','Demon','Elf');
switch input
case 1
hunter=menu('The Hunter is a character that prefers to fight from a distance. Do you want the Hunter?','Yes','No');
switch hunter
case 1
disp('Congratulation you have chosen the Hunter. Your journey is about to begin.')
break;
case 2
end
case 2
disp('The Warrior is a character with a high strength.')
break;
case 3
disp('The Mage is a Character that attacks with magic from a distance.')
break;
end
end
I also fixed misspellings of character, journey, congratulations, etc.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!