Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Gruppe44-PROG1003-2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Blakli
Gruppe44-PROG1003-2022
Commits
d37f229f
Commit
d37f229f
authored
3 years ago
by
Andreas Blakli
Browse files
Options
Downloads
Patches
Plain Diff
La til:
lesfraFil() funk. skrivTilFil() funk. i Baneklassen i filene bane.h og bane.cpp.
parent
0afe80c5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bane.cpp
+33
-7
33 additions, 7 deletions
bane.cpp
bane.h
+5
-0
5 additions, 0 deletions
bane.h
with
38 additions
and
7 deletions
bane.cpp
+
33
−
7
View file @
d37f229f
...
...
@@ -3,22 +3,21 @@
using
namespace
std
;
Bane
::
Bane
()
:
Rute
()
{
lesData
();
//
lesData();
}
Bane
::~
Bane
()
{
}
void
Bane
::
lesData
()
{
antallVogner
=
lesInt
(
"Antall vogner"
,
MIN_ANTALL_VOGNER
,
MAX_ANTALL_VOGNER
);
baneLengde
=
lesInt
(
"Banelengde"
,
MIN_BANELENGDE
,
MAX_BANELENGDE
);
}
void
Bane
::
skrivData
()
{
cout
<<
"
\n
Antall vogner: "
<<
antallVogner
<<
'\n'
<<
"Banelengde: "
<<
baneLengde
;
cout
<<
"
\n\t
..::Bane info::.."
<<
'\n'
;
cout
<<
"
\n\t
Antall vogner: "
<<
antallVogner
<<
'\n'
<<
"
\t
Banelengde: "
<<
baneLengde
;
}
void
Bane
::
skrivType
()
{
...
...
@@ -26,13 +25,40 @@ void Bane::skrivType() {
}
void
Bane
::
skrivDataForlengs
()
{
skrivType
();
skrivData
();
Rute
::
skrivDataForlengs
();
cout
<<
"
\n\n
"
;
}
void
Bane
::
skrivDataBaklengs
()
{
skrivType
();
skrivData
();
Rute
::
skrivDataBaklengs
();
cout
<<
"
\n\n
"
;
}
void
Bane
::
lesFraFil
(
ifstream
&
inn
)
{
int
i
=
0
;
string
heleLinjen
=
""
;
getline
(
inn
,
heleLinjen
);
vector
<
string
>
linjenSplittet
=
hjelp
.
splittStreng
(
'*'
,
heleLinjen
);
for
(
const
auto
&
val
:
linjenSplittet
)
{
switch
(
i
)
{
case
0
:
antallVogner
=
stoi
(
val
);
break
;
case
1
:
baneLengde
=
stoi
(
val
);
break
;
}
i
++
;
}
Rute
::
lesFraFil
(
inn
);
}
void
Bane
::
skrivTilFil
(
ofstream
&
ut
)
{
ut
<<
"Bane"
<<
'\n'
<<
antallVogner
<<
'*'
<<
baneLengde
<<
'*'
<<
'\n'
;
Rute
::
skrivTilFil
(
ut
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bane.h
+
5
−
0
View file @
d37f229f
...
...
@@ -2,15 +2,18 @@
#define __BANE_H
#include
<iostream>
#include
<fstream>
#include
"konstanter.h"
#include
"lesData3.h"
#include
"rute.h"
#include
"hjelpeFunksjoner.h"
class
Bane
:
public
Rute
{
private:
int
antallVogner
;
int
baneLengde
;
HjelpeFunksjoner
hjelp
;
public:
Bane
();
...
...
@@ -20,6 +23,8 @@ class Bane : public Rute {
void
skrivType
();
void
skrivDataForlengs
();
void
skrivDataBaklengs
();
void
lesFraFil
(
std
::
ifstream
&
inn
);
void
skrivTilFil
(
std
::
ofstream
&
ut
);
};
#endif // __BANE_H
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment