Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<stdexcept>
- #include <cmath>
- class Robot {
- double x, y, ugao;
- public:
- Robot () {Robot::x=0; Robot::y=0; Robot::ugao=0;};
- explicit Robot (double ugao) {Robot::x=0; Robot::y=0; Robot::ugao=ugao;};
- Robot(double x, double y, double ugao) {Robot::x=x; Robot::y=y; Robot::ugao=ugao;};
- void IdiNaprijed(double pomak);
- void IdiNazad(double pomak);
- void OkreniSeNaijevo(double ugao) {Robot::ugao+=ugao;};
- void OkreniSeNadesno(double ugao) {Robot::ugao-=ugao;};
- double DajPozicijuX() const {return Robot::x;};
- double DajPozicijuY() const {return Robot::y; };
- double DajOrjent9aciju() const {return Robot::ugao; };
- void Ispisi() const;
- };
- void Robot::IdiNaprijed(double pomak) {
- Robot::x+=pomak*cos(Robot::ugao);
- Robot::y+=pomak*sin(Robot::ugao);
- }
- void Robot::IdiNazad(double pomak) {
- Robot::x-=pomak*cos(Robot::ugao+180);
- Robot::y-=pomak*sin(Robot::ugao+180);
- }
- void Robot::Ispisi () const {
- std::cout<<"Robot se nalazi na poziciji ("<<x<<","<<y<<") i gleda pod uglom "<<ugao<<" stepeni u odnosu na x osu.";
- }
- int main () {
- Robot r1(3,5,30);
- r1.IdiNaprijed (3);
- r1.Ispisi();
- return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement