Skip to content
Snippets Groups Projects
Commit 1663dced authored by Frederik Simonsen's avatar Frederik Simonsen
Browse files

oppdateringer på stoppesteder og stoppested

parent d4ac2218
No related branches found
No related tags found
No related merge requests found
......@@ -50,3 +50,10 @@ string Stoppested::hentStoppestedNavn() {
void Stoppested::skrivData() {
cout << setw(20) << navn;
}
/**
* skrivTilFil(...)
*/
void Stoppested::skrivTilFil(ofstream & ut) {
ut << navn << '\n';
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ class Stoppested {
std::string hentStoppestedNavn();
void skrivData();
void lesData();
void skrivTilFil(std::ofstream & ut);
};
#endif
\ No newline at end of file
......@@ -66,15 +66,18 @@ void Stoppesteder::lesFraFil() {
ifstream innfilS("Stoppesteder.dta");
string navn;
int antStopp;
int n = 0;
if (innfilS) {
innfilS >> antStopp; innfilS.ignore();
cout << "Leser " << antStopp
<< " stoppesteder fra 'stoppested.dta'...\n";
getline(innfilS, navn);
while (!innfilS.eof()) {
while (n < antStopp) {
stopper.push_back(new Stoppested(navn, innfilS));
getline(innfilS, navn);
n++;
}
cout << "test";
innfilS.close();
}
}
......@@ -146,5 +149,11 @@ void Stoppesteder::skrivMeny() {
* Skriver informasjon om stoppesteder til fil
*/
void Stoppesteder::skrivTilFil() {
ofstream utfil("Stoppesteder.dt2");
cout << "\nSkriver til filen stoppesteder.dt2...\n";
utfil << stopper.size() << '\n';
for (int i = 0; i < stopper.size(); i++) {
stopper[i]->skrivTilFil(utfil);
}
utfil.close();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment