0
코드의이 특정 부분에서 Xcode는 다음 오류를 찾습니다. '이동'참조가 모호합니다. 또한 그것은 다음과 같이 말합니다 : 열거 형 값 'move'는 스위치에서 처리되지 않습니다. 그 값을 가진 클래스가 포함되어 있기 때문에 난센스입니다.'이동'에 대한 참조가 모호합니다.
enum provinceName {anjou, flandre, gascogne, bretagne};
enum compassPoint {U, R, D, L};
enum recommendation {move, nothing, lft, rght, rear, attck};
enum id {empty, ally, enemy, abyss};
// this struct is given to the unit when a recommendation is requested
struct intel{
id inFront;
int inFrontNum;
id inRear;
int inRearNum;
id inLeft;
int inLeftNum;
id inRight;
int inRightNum;
compassPoint nearestEnemyDir;
int nearestEnemyDist;
int nearestEnemyNum;
compassPoint weakestEnemyDir;
int weakestEnemyDist;
int weakestEnemyNum;
compassPoint strongestEnemyDir;
int strongestEnemyDist;
int strongestEnemyNum;
compassPoint nearestAllyDir;
int nearestAllyDist;
int nearestAllyNum;
compassPoint weakestAllyDir;
int weakestAllyDist;
int weakestAllyNum;
compassPoint strongestAllyDir;
int strongestAllyDist;
int strongestAllyNum;
};
class gamePiece{
public:
// return the status of the alive variable
bool onBoard();
// return the current x value
int getX();
// return the current y value
int getY();
// return the current direction
compassPoint getDir();
// return the number of soldiers in the unit
int getNumElements();
// return the province
provinceName getProvince();
// set alive to false
void die();
// change the direction for a left turn
void turnLeft();
// change the direction for right turn
void turnRight();
// change the direction for an about face
void aboutFace();
// change x and y for a forward move
void moveForward();
// roll a die for each soldier in the unit.
// each 5 or 6 counts as a 'hit'.
// return the number of hits.
int attack();
//return lft, rght, rear, move, attck, or nothing
recommendation recommend(intel sitRep);
// reduce the number of soldiers by hits
int suffer(int hits);
// construct a nonliving gamepiece
gamePiece();
// construct a living gamepeice
gamePiece(int col, int row, compassPoint direction, int num, provinceName p);
private:
int numSoldiers;
int x;
int y;
compassPoint dir;
provinceName province;
bool alive;
};
사람이 문제가 될 것으로 보인다 무엇인지 찾아 주시겠습니까 다음과 같이
while(!done){
//m=rand()%NUM;
for(m=0;m<NUM;++m){
if(piece[m].onBoard()){
sitRep=getIntel(piece,m);
r=piece[m].recommend(sitRep);
switch(r){
case nothing: break;
case lft: piece[mn].turnLeft(); break;
case rght: piece[m].turnRight(); break;
case rear: piece[m].aboutFace(); break;
case move:
piece[m].moveForward();
if(piece[m].getX()<0||piece[m].getX()>=DIM)piece[m].die();
if(piece[m].getY()<0||piece[m].getY()>=DIM)piece[m].die();
break;
case attck:
hits=piece[m].attack();
makeSuffer(piece,m,hits);
break;
}
if(line[0]=='q')done=true;
}
}
클래스는 무엇입니까? 감사합니다.
팁 주셔서 감사합니다! 임무를 아직 이해할 수 없다 :) – user1563544