当前位置: 首页>>代码示例>>C++>>正文


C++ board::shipOn方法代码示例

本文整理汇总了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);

}
开发者ID:joses97,项目名称:SanchezJose_CSC17a_42824,代码行数:71,代码来源:funcs.cpp


注:本文中的board::shipOn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。