-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodos.cpp
More file actions
40 lines (34 loc) · 891 Bytes
/
nodos.cpp
File metadata and controls
40 lines (34 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <cmath>
#include "nodos.hpp"
using namespace std;
nodo::nodo(int t, int i, float x, float y) {
tipo = t;
id = i;
coordX = x;
coordY = y;
demanda = 0;
}
void nodo::print() {
cout << "Nodo " << id << "\n";
if (tipo == 0) {
cout << " Tipo: Depósito\n";
} else if (tipo == 1) {
cout << " Tipo: Linehaul\n";
} else if (tipo == 2) {
cout << " Tipo: Backhaul\n";
} else {
cout << " Tipo: Desconocido\n";
}
cout << " Demanda: " << demanda << "\n";
cout << " Coord: (" << coordX << ", " << coordY << ")\n" << endl;
}
float nodo::dist(nodo uno) {
int xs = pow(uno.coordX - coordX, 2);
int ys = pow(uno.coordY - coordY, 2);
float distancia = sqrt(xs + ys);
return distancia;
}
void nodo::set_d(int d) {
demanda = d;
}