Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- class Point
- {
- string id;
- double vx;
- double vy;
- double vz;
- double m;
- public:
- Point(string id = "~",
- double vx = 0,
- double vy = 0,
- double vz = 0,
- double m = 0)
- {
- this->id = id;
- this->vx = vx;
- this->vy = vy;
- this->vz = vz;
- this->m = m;
- }
- void printPoint()
- {
- cout << "label: " << id << '\n'
- << "x_velocity: " << vx << '\n'
- << "y_velocity: " << vy << '\n'
- << "z_velocity: " << vz << '\n'
- << "mass: " << m << "\n\n";
- }
- };
- class Space
- {
- vector<Point> points;
- public:
- void add(string id, double vx, double vy, double vz, double m)
- {
- class Point *to_add = new Point(id, vx, vy, vz, m);
- this->points.push_back(*to_add);
- }
- void qdm(double &px, double &py, double &pz);
- // qui fa il for di tutti gli elementi del vettore e calcola la qta di moto
- string fastest();
- // ancora col for li scorre e si segna l'id del più veloce
- void printSpace()
- {
- for (auto i = this->points.begin(); i != this->points.end(); i++)
- i->printPoint();
- }
- };
- int main()
- {
- Space *s = new Space();
- s->add("punto 1", 5, 6, 7, 8);
- s->add("punto 2", 2, 3, 6, 6);
- s->add("punto 3", 1, 4, 9, 7);
- s->printSpace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement