Tennis using C++
#include<iostream>
using namespace std;
class tennis
{
char plname1[100];
char country1[100];
char plname2[100];
char country2[100];
char fltype[100];
char flcolor[100];
int point1,point2;
public:
void s_plname1(char *m)
{
strcpy(plname1,m);
}
void s_country1(char *m)
{
strcpy(country1,m);
}
void s_country2(char *m)
{
strcpy(country2,m);
}
void s_plname2(char *m)
{
strcpy(plname2,m);
}
void s_fltype(char *m)
{
strcpy(fltype,m);
}
void s_flcolor(char *m)
{
strcpy(flcolor,m);
}
void s_point1(int k)
{
point1=k;
}
void s_point2(int k)
{
point2=k;
}
void show1()
{
cout<<" "<<"1ST player name : "<<plname1<<endl;
cout<<" "<<"He is from : "<<country1<<endl;
cout<<" "<<"2ND player name : "<<plname2<<endl;
cout<<" "<<"He is from : "<<country2<<endl;
cout<<" "<<"your field type is : "<<fltype<<endl;
cout<<" "<<"your field color is : "<<flcolor<<endl;
cout<<" "<<"1st player point is : "<<point1<<endl;
cout<<" "<<"2nd player point is : "<<point2<<endl;
}
};
int main()
{
tennis ob1;
cout<<"Lets GO...Start your tennis game!!!!!!!\n"<<endl;
char X[100],Y[100];int m=1,n=1;
cout<<"enter your 1st player name : ";
cin>>X;
ob1.s_plname1(X);
cout<<endl;
cout<<"enter his country : ";
cin>>X;
ob1.s_country1(X);cout<<endl;
cout<<"enter your 2nd player name : ";
cin>>Y;
ob1.s_plname2(Y);
cout<<endl;
cout<<"enter his country : ";
cin>>Y;
ob1.s_country2(Y);
cout<<endl;
cout<<"enter your field type : ";
cin>>X;
ob1.s_fltype(X);
cout<<endl;
cout<<"enter your field color : ";
cin>>X;
ob1.s_flcolor(X);
cout<<endl;
for(;m>=1,n>=1 ;){level: cout<<"enter 1st player point : ";
cout<<endl;
cin>>m;
ob1.s_point1(m);
cout<<endl;cout<<"enter 2nd player point : ";
cout<<endl;
cin>>n;
ob1.s_point2(n);
cout<<endl<<endl<<endl;
ob1.show1();cout<<endl<<endl<<endl;
if(m>=41||n>=41)
{
cout<<"......Please enter between 1-40......."<<endl;
break;
}
if(m>n)
{
cout<<" !!!!!!!!! 1st player win the set !!!!!!!!!!!"<<endl<<endl;
}
else
{
if(m==n)
{
cout<<" set is tie && give different points "<<endl<<endl;
}
else
{
cout<<" !!!!!!!!! 2nd player win the set !!!!!!!!!!!"<<endl<<endl;
}
goto level;
}
}
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment