-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.cc
More file actions
97 lines (79 loc) · 3.36 KB
/
message.cc
File metadata and controls
97 lines (79 loc) · 3.36 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// message.cc : fonctions pour l'affichage des messages d'erreur
// Version 1.2: fonctions supplémentaire pour indiquer le succès de la lecture
// Version 1.1: 9 fonctions de messages d'erreurs à utiliser pour le projet
//
#include "message.h"
using namespace std;
namespace
{
void reorder_for_consistency(double & x1, double & y1, double & x2, double & y2)
{
if(x1 > x2 || (x1 == x2 && y1 > y2))
{
swap(x1, x2);
swap(y1, y2);
}
}
}
string message::particle_outside(double x, double y, double s)
{
return string("Particle at (") + to_string(x) + string(";") + to_string(y)
+ string(") of size ") + to_string(s) + string(" is outside boundaries\n");
}
string message::particle_too_small(double x, double y, double s)
{
return string("Particle at (") + to_string(x) + string(";") + to_string(y)
+ string(") of size ") + to_string(s) + string(" is too small\n");
}
string message::spatial_robot_ouside(double x, double y)
{
return string("Spatial robot at (") + to_string(x) + string(";") + to_string(y)
+ string(") is outside boundaries\n");
}
std::string message::invalid_k_update(double x, double y, int k_update, int max_update)
{
return string("A robot at (") + to_string(x) + string(";") + to_string(y)
+ string(") has a k_update of ") + to_string(k_update)
+ string(" which is greater than the maximum of ") + to_string(max_update)
+ string("\n");
}
string message::particle_superposition(double x1, double y1, double x2, double y2)
{
reorder_for_consistency(x1, y1, x2, y2);
return string("Particle at (") + to_string(x1) + string(";") + to_string(y1)
+ string(") and particle at (") + to_string(x2) + string(";") + to_string(y2)
+ string(") are in superposition\n");
}
string message::repairers_superposition(double x1, double y1, double x2, double y2)
{
reorder_for_consistency(x1, y1, x2, y2);
return string("Repairer at (") + to_string(x1) + string(";") + to_string(y1)
+ string(") and repairer at (") + to_string(x2) + string(";") + to_string(y2)
+ string(") are in superposition\n");
}
string message::neutralizers_superposition(double x1, double y1, double x2, double y2)
{
reorder_for_consistency(x1, y1, x2, y2);
return string("Neutralizer at (") + to_string(x1) + string(";") + to_string(y1)
+ string(") and neutralizer at (") + to_string(x2) + string(";")
+ to_string(y2) + string(") are in superposition\n");
}
string message::repairer_neutralizer_superposition(double xr, double yr,
double xn, double yn)
{
return string("Repairer at (") + to_string(xr) + string(";") + to_string(yr)
+ string(") and neutralizer at (") + to_string(xn) + string(";")
+ to_string(yn) + string(") are in superposition\n");
}
std::string message::particle_robot_superposition(double xp, double yp, double sp,
double xr, double yr, double rr)
{
return string("Particle at (") + to_string(xp) + string(";") + to_string(yp)
+ string(") of size ") + to_string(sp) + string(" and robot at (")
+ to_string(xr) + string(";") + to_string(yr) + string(") of radius ")
+ to_string(rr) + string(" are in superposition\n");
}
string message::success()
{
return string("Correct file\n");
}