-
Notifications
You must be signed in to change notification settings - Fork 1
/
ListOfPoint.cpp
65 lines (61 loc) · 1.67 KB
/
ListOfPoint.cpp
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
#include <iostream>
#include <vector>
#include "ListOfPoint.hpp"
#include "Point.hpp"
#include <utility>
using namespace std;
void ListOfPoint::setVecPoint(vector<Point> _vecP, unsigned int numb){
vecPoint=_vecP;
numbOfPoint=numb;
}
vector<Point> ListOfPoint::getVecPoint(){
return vecPoint;
}
unsigned int ListOfPoint::getNumbPoint(){
return numbOfPoint;
}
void ListOfPoint::append()
{
string str;
pair<float,float> coord;
try {
cout << "Введите название точки:\n (В виде KXXX - если аэропорт)\n(В виде XXXXX - если точка промежуточная): ";
cin.ignore(1,'\n');
getline(cin, str);
cout<<"Введите координаты точки:"<<endl<<"Широта:";
cin>>coord.first;
cout<<"Долгота:";
cin>>coord.second;
for(unsigned int i=0; i<numbOfPoint; i++) {
if(str==vecPoint[i].getName())
throw 1;
}
Point point(str,coord);
vecPoint.push_back(point);
numbOfPoint++;
cout << "Точка добавлена!"<<endl;
}
catch(int err) {
cout << "Ошибка! Точка уже существует!" <<endl;
}
}
void ListOfPoint::remove(){
string poi;
int flag,n;
cout<<"Введите название точки:";
cin.ignore(1,'\n');
getline(cin,poi);
for(unsigned int i=0;i<vecPoint.size();i++){
if(poi==vecPoint[i].getName()){
flag=1;
n=i;
}
}
if(flag==1){
vecPoint.erase(vecPoint.begin()+n);
cout<<"Точка удалена"<<endl;
numbOfPoint--;
}
else
cout<<"Точка не найдена"<<endl;
}