55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
//
|
|
// Created by Nik on 11/04/2022.
|
|
//
|
|
|
|
#include "Vlak.h"
|
|
|
|
|
|
void Vlak::addPriklucek(Prikljucek *p) {
|
|
vlak.push_back(p);
|
|
}
|
|
|
|
std::string Vlak::toString() const {
|
|
std::string ret;
|
|
for(auto v:vlak){
|
|
ret += v->toString();
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
std::vector<Prikljucek*> Vlak::generate(unsigned int amount) {
|
|
std::vector<Prikljucek*> ret;
|
|
|
|
for(int i = 0; i < amount; i++) {
|
|
if (rand() % 2 == 1) {
|
|
int y = (int) rand() % 2;
|
|
TipVag tp;
|
|
switch (y) {
|
|
case 0:
|
|
tp = TipVag::Potniski;
|
|
break;
|
|
case 1:
|
|
tp = TipVag::Tovorni;
|
|
break;
|
|
}
|
|
//Vagon j(rand() % 100, rand() % 100, tp);
|
|
ret.push_back(new Vagon(100, 100, tp));
|
|
|
|
} else {
|
|
// Lokomotiva k(rand()%100, rand()%100,rand()%1000+1);
|
|
ret.push_back(new Lokomotiva(rand() % 100, rand() % 100, rand() % 1000 + 1));
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
unsigned int Vlak::lenghtOfTranin() const {
|
|
unsigned int len = 0;
|
|
for(auto t: vlak){
|
|
len += t->getLenght();
|
|
}
|
|
return len;
|
|
}
|
|
|
|
|