Judge。h
- #import <Foundation/Foundation.h>
- #import "Player.h"
- #import "Robot.h"
- @interface Judge : NSObject{
- @public
- NSString *_name;
- }
- - (void)show;
- - (void)caiJueWithPlayer :(Player *)player andRobot:(Robot *)robot;
- @end
复制代码
judge。m
- #import "Judge.h"
- @implementation Judge
- - (void)show{
- NSLog(@"\n我是裁判[%@],我来宣布结果!",_name);
- }
- - (void)caiJueWithPlayer :(Player *)player andRobot:(Robot *)robot{
- if (player->_select - robot->_select == -2 || player->_select - robot->_select == 1) {
- NSLog(@"恭喜选手[%@]获得胜利!",player->_name);
- player->_score++;
- NSLog(@"目前比分 : [%@]%d : [%@]%d",
- player->_name,player->_score,robot->_name,robot->_score);
- }else if (player->_select == robot->_select){
- NSLog(@"平局");
- NSLog(@"目前比分 : [%@]%d : [%@]%d",
- player->_name,player->_score,robot->_name,robot->_score);
- }else{
- NSLog(@"恭喜机器人[%@]获得胜利!",robot->_name);
- robot->_score++;
- NSLog(@"目前比分 : [%@]%d : [%@]%d",
- player->_name,player->_score,robot->_name,robot->_score);
- }
- }
- @end
复制代码
select。h
- typedef enum{
- SelectJianDao = 1,
- SelectShiTou = 2,
- SelectBu = 3
- } Select ;
复制代码 |