Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main.cpp
- #include <iostream>
- #include "Point.h"
- #include "Circle.h"
- int main() {
- Point p(1.3, 1.4);
- std::cout << p.print();
- Circle c(p, 0.5);
- std::cout << c.print();
- c.move(1.7, 1.6);
- std::cout << c.print();
- /*
- Point p(4, 5);
- std::cout << p.getX() << std::endl;
- std::cout << p.print();
- p.move(3,4);
- std::cout << p.print();
- Point * ptr = new Point(7,9);
- double *fpt = ptr->getX();
- std::cout << ptr->getX() << std::endl;
- std::cout << ptr.print();
- *ptr->move(3,11);
- ptr->move(3,11);
- std::cout << ptr->print();
- */
- return 0;
- }
- //circle.cpp
- #include "circle.h"
- //circle.h
- #ifndef _POINT_H
- #define _POINT_H
- #include <string>
- #include <sstream>
- class Point {
- double x, y;
- public:
- Point() {
- x = 0;
- y = 0;
- }
- Point(double a, double b) {
- x = a;
- y = b;
- }
- void move(double dx, double dy) {
- x += dx;
- y += dy;
- }
- std::string print(bool zeilenvorschub = true) {
- if(zeilenvorschub) {
- std::ostringstream ss;
- ss << "(" << x << ", " << y << ")" << std::endl;
- return ss.str();
- }
- if (!zeilenvorschub) {
- std::ostringstream ss;
- ss << "(" << x << ", " << y << ")";
- return ss.str();
- }
- }
- double getX() {
- return x;
- }
- };
- #endif // _POINT_H
- //point.cpp
- #include "point.h"
- //point.h
- #ifndef _POINT_H
- #define _POINT_H
- #include <string>
- #include <sstream>
- class Point {
- double x, y;
- public:
- Point() {
- x = 0;
- y = 0;
- }
- Point(double a, double b) {
- x = a;
- y = b;
- }
- void move(double dx, double dy) {
- x += dx;
- y += dy;
- }
- std::string print(bool zeilenvorschub = true) {
- if(zeilenvorschub) {
- std::ostringstream ss;
- ss << "(" << x << ", " << y << ")" << std::endl;
- return ss.str();
- }
- if (!zeilenvorschub) {
- std::ostringstream ss;
- ss << "(" << x << ", " << y << ")";
- return ss.str();
- }
- }
- double getX() {
- return x;
- }
- };
- #endif // _POINT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement