【发布时间】:2017-03-04 15:27:00
【问题描述】:
我想比较石头剪刀布游戏文本框中的字符串。比较后,将结果显示在另一个文本框中。但它没有比较。有人可以帮帮我吗?谢谢你。
if strcmp('Rock'==get(handles.computer,'string'),'Rock'==get(handles.player,'string'))
set(handles.result,'string','Draw');
elseif strcmp('Rock'==get(handles.computer,'string'),'Paper'==get(handles.player,'string'))
set(handles.result,'string','Player wins');
elseif strcmp('Rock'==get(handles.computer,'string'),'Scissors'==get(handles.player,'string'))
set(handles.result,'string','Computer wins');
elseif strcmp('Paper'==get(handles.computer,'string'),'Rock'==get(handles.player,'string'))
set(handles.result,'string','Computer wins');
elseif strcmp('Paper'==get(handles.computer,'string'),'Paper'==get(handles.player,'string'))
set(handles.result,'string','Draw');
elseif strcmp('Paper'==get(handles.computer,'string'),'Scissors'==get(handles.player,'string'))
set(handles.result,'string','Player wins');
elseif strcmp('Scissors'==get(handles.computer,'string'),'Rock'==get(handles.player,'string'))
set(handles.result,'string','Player wins');
elseif strcmp('Scissors'==get(handles.computer,'string'),'Paper'==get(handles.player,'string'))
set(handles.result,'string','Computer wins');
elseif strcmp('Scissors'==get(handles.computer,'string'),'Scissors'==get(handles.player,'string'))
set(handles.result,'string','Draw');
end
【问题讨论】: