Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class kursor
- {
- int x,y;
- public:
- void ustal(int a=0, int b=0)
- {
- if((a<80)&& (b<25))
- {
- this->x=a;
- this->y=b;
- }
- else
- {
- cout<<"podales bledne wspolzedne"<<endl;
- this->x=0;
- this->y=0;
- }
- }
- void doGory();
- void doDolu();
- void wPrawo();
- void wLewo();
- void oWektor(int a,int b);
- void pokaz()
- {
- cout<<"x="<<x<<endl;
- cout<<"y="<<y<<endl;
- }
- };
- void kursor::doGory()
- {
- if(x!=80) x=x+1;
- else cout<<"kursor osiagnal kres ekranu"<<endl;
- }
- void kursor::doDolu()
- {
- if(x!=0) x=x-1;
- else cout<<"kursor osiagnal kres ekranu"<<endl;
- }
- void kursor::wLewo()
- {
- if(y!=0) y=y-1;
- else cout<<"kursor osiagnal kres ekranu"<<endl;
- }
- void kursor::wPrawo()
- {
- if(y!=25) y=y+1;
- else cout<<"kursor osiagnal kres ekranu"<<endl;
- }
- void kursor::oWektor(int a,int b)
- {
- if(x+a<80 && x+a>0)
- x=x+a;
- if(y+b<25 && y+b>0)
- y=y+b;
- }
- int main()
- {
- // cout << "Hello world!" << endl;
- kursor a,b,c,d;
- a.ustal(0,0);
- b.ustal(3,1);
- c.ustal(42,54);
- d.ustal(1,2);
- a.pokaz();
- a.oWektor(11,12);
- a.oWektor(-25,-25);
- a.pokaz();
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement