SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | ||
| 3 | using namespace std; | |
| 4 | ||
| 5 | class kursor | |
| 6 | {
| |
| 7 | int x,y; | |
| 8 | public: | |
| 9 | - | void ustal() |
| 9 | + | void ustal(int a=0, int b=0) |
| 10 | {
| |
| 11 | - | int a,b; |
| 11 | + | |
| 12 | - | cout<<"podaj wspolzedne x"<<endl; |
| 12 | + | |
| 13 | - | cin>>a; |
| 13 | + | |
| 14 | - | cout<<"podaj wspolzedne y"<<endl; |
| 14 | + | |
| 15 | - | cin>>b; |
| 15 | + | |
| 16 | } | |
| 17 | else | |
| 18 | {
| |
| 19 | cout<<"podales bledne wspolzedne"<<endl; | |
| 20 | this->x=0; | |
| 21 | this->y=0; | |
| 22 | } | |
| 23 | ||
| 24 | } | |
| 25 | void doGory(); | |
| 26 | void doDolu(); | |
| 27 | void wPrawo(); | |
| 28 | void wLewo(); | |
| 29 | void oWektor(int a,int b); | |
| 30 | - | |
| 30 | + | |
| 31 | - | |
| 31 | + | |
| 32 | void pokaz() | |
| 33 | {
| |
| 34 | cout<<"x="<<x<<endl; | |
| 35 | cout<<"y="<<y<<endl; | |
| 36 | } | |
| 37 | ||
| 38 | }; | |
| 39 | ||
| 40 | void kursor::doGory() | |
| 41 | {
| |
| 42 | if(x!=80) x=x+1; | |
| 43 | - | a.ustal(); |
| 43 | + | else cout<<"kursor osiagnal kres ekranu"<<endl; |
| 44 | - | b.ustal(); |
| 44 | + | |
| 45 | - | c.ustal(); |
| 45 | + | |
| 46 | - | d.ustal(); |
| 46 | + | void kursor::doDolu() |
| 47 | {
| |
| 48 | - | |
| 48 | + | if(x!=0) x=x-1; |
| 49 | else cout<<"kursor osiagnal kres ekranu"<<endl; | |
| 50 | ||
| 51 | } | |
| 52 | void kursor::wLewo() | |
| 53 | - | } |
| 53 | + | |
| 54 | if(y!=0) y=y-1; | |
| 55 | else cout<<"kursor osiagnal kres ekranu"<<endl; | |
| 56 | ||
| 57 | } | |
| 58 | void kursor::wPrawo() | |
| 59 | {
| |
| 60 | if(y!=25) y=y+1; | |
| 61 | else cout<<"kursor osiagnal kres ekranu"<<endl; | |
| 62 | ||
| 63 | } | |
| 64 | void kursor::oWektor(int a,int b) | |
| 65 | {
| |
| 66 | if(x+a<80 && x+a>0) | |
| 67 | x=x+a; | |
| 68 | if(y+b<25 && y+b>0) | |
| 69 | y=y+b; | |
| 70 | ||
| 71 | } | |
| 72 | ||
| 73 | ||
| 74 | ||
| 75 | ||
| 76 | ||
| 77 | int main() | |
| 78 | {
| |
| 79 | // cout << "Hello world!" << endl; | |
| 80 | kursor a,b,c,d; | |
| 81 | a.ustal(0,0); | |
| 82 | b.ustal(3,1); | |
| 83 | c.ustal(42,54); | |
| 84 | d.ustal(1,2); | |
| 85 | a.pokaz(); | |
| 86 | ||
| 87 | a.oWektor(11,12); | |
| 88 | a.oWektor(-25,-25); | |
| 89 | a.pokaz(); | |
| 90 | ||
| 91 | ||
| 92 | ||
| 93 | ||
| 94 | ||
| 95 | return 0; | |
| 96 | }; |