Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. class Point
  6. {
  7.     string id;
  8.     double vx;
  9.     double vy;
  10.     double vz;
  11.     double m;
  12.     public:
  13.        
  14.         Point(string id = "~",
  15.                 double vx = 0,
  16.                 double vy = 0,
  17.                 double vz = 0,
  18.                 double m = 0)
  19.         {
  20.             this->id = id;
  21.             this->vx = vx;
  22.             this->vy = vy;
  23.             this->vz = vz;
  24.             this->m = m;
  25.         }
  26.        
  27.         void printPoint()
  28.         {
  29.             cout << "label: " << id << '\n'
  30.                 << "x_velocity: " << vx << '\n'
  31.                 << "y_velocity: " << vy << '\n'
  32.                 << "z_velocity: " << vz << '\n'
  33.                 << "mass: " << m << "\n\n";
  34.         }
  35. };
  36.  
  37.  
  38.  
  39. class Space
  40. {
  41.     vector<Point> points;
  42.    
  43.     public:
  44.        
  45.         void add(string id, double vx, double vy, double vz, double m)
  46.         {
  47.             class Point *to_add = new Point(id, vx, vy, vz, m);
  48.             this->points.push_back(*to_add);
  49.         }
  50.        
  51.         void qdm(double &px, double &py, double &pz);
  52.         // qui fa il for di tutti gli elementi del vettore e calcola la qta di moto
  53.         string fastest();
  54.         // ancora col for li scorre e si segna l'id del più veloce
  55.        
  56.         void printSpace()
  57.         {
  58.             for (auto i = this->points.begin(); i != this->points.end(); i++)
  59.                 i->printPoint();
  60.         }  
  61. };
  62.  
  63.  
  64.  
  65. int main()
  66. {
  67.     Space *s = new Space();
  68.     s->add("punto 1", 5, 6, 7, 8);
  69.     s->add("punto 2", 2, 3, 6, 6);
  70.     s->add("punto 3", 1, 4, 9, 7);
  71.     s->printSpace();
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement