本文整理汇总了C++中board::shipOn方法的典型用法代码示例。如果您正苦于以下问题:C++ board::shipOn方法的具体用法?C++ board::shipOn怎么用?C++ board::shipOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board
的用法示例。
在下文中一共展示了board::shipOn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inputS
//******************************************************************************
//******************************************************************************
//This function is used to get the coordinates of the users ships
void inputS(board &player, int i){
int x=0;
int y=0;
int x2=0;
int y2=0;
char Cypos;
bool reDo=false;
//enter
do{
reDo=false;
cout<<"Enter "<<player.getN(i)<<" which is of size"
" "<<player.getSzs(i)<<endl;
cout<<"enter the initial x position 1-10"<<endl;
do{
cin>>x;
try{
if(x>10||x<1)
{
string error1="Please enter a value between 1 and 10";
throw error1;
}
}
catch (string error1)
{
cout<<error1<<endl;
}
}while(x>10||x<1);
//enter
do{
cout<<"enter the initial y position A-J"<<endl;
cin>>Cypos;
}while(CtoInt(toupper(Cypos))==11);
//convert
y=CtoInt(toupper(Cypos));
//enter
do{
cout<<"enter the final x position 1-10"<<endl;
cin>>x2;
}while(x2>10||x2<1);
//enter
do{
cout<<"enter the final y position A-J"<<endl;
cin>>Cypos;
}while(CtoInt(toupper(Cypos))==11);
//convert
y2=CtoInt(toupper(Cypos));
try{
reDo=player.testCor(i, x, y, x2, y2);
}
catch(board::invalid){
cout<<endl;
cout<<"Invalid Coordinates were entered"<<endl;
cout<<"Re-Enter Values with the with correct size"<<endl;
cout<<endl;
player.display();
}
}while(!reDo);
//create ship with initial x and pos positions
player.makeShp(i, x, y, x2, y2);
player.shipOn(i);
player.disCoor(i);
player.fillrest(i);
}