Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
ohj2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
hiltunma
ohj2
Commits
d4e75d51
Commit
d4e75d51
authored
1 week ago
by
Hiltunen Markus Petteri
Browse files
Options
Downloads
Patches
Plain Diff
Suorituksien lisääminen tiedostoon.
parent
4fcc67aa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/reittiLoki/Suoritukset.java
+22
-1
22 additions, 1 deletion
src/reittiLoki/Suoritukset.java
src/reittiLoki/Suoritus.java
+28
-2
28 additions, 2 deletions
src/reittiLoki/Suoritus.java
suoritukset/suoritukset.dat
+3
-1
3 additions, 1 deletion
suoritukset/suoritukset.dat
with
53 additions
and
4 deletions
src/reittiLoki/Suoritukset.java
+
22
−
1
View file @
d4e75d51
...
...
@@ -4,6 +4,8 @@ import java.io.File;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.PrintStream
;
import
java.util.Scanner
;
import
java.io.FileInputStream
;
/**
* @author OMISTAJA
...
...
@@ -58,7 +60,19 @@ public int getLkm() {
*/
public
void
lueTiedostosta
(
String
hakem
)
throws
SailoException
{
tiedostoNimi
=
hakem
+
"/suoritukset.dat"
;
throw
new
SailoException
(
"Ei osata vielä lukea tiedostoa"
);
File
tied
=
new
File
(
tiedostoNimi
);
try
(
Scanner
fi
=
new
Scanner
(
new
FileInputStream
(
tied
))){
while
(
fi
.
hasNext
())
{
String
seuraava
=
fi
.
nextLine
();
if
(
seuraava
==
null
||
""
.
equals
(
seuraava
)
||
seuraava
.
charAt
(
0
)
==
';'
)
continue
;
Suoritus
suoritus
=
new
Suoritus
();
suoritus
.
parse
(
seuraava
);
lisaa
(
suoritus
);
}
}
catch
(
FileNotFoundException
e
)
{
throw
new
SailoException
(
"Ei saada luettua tiedostoa"
);
}
}
/**
...
...
@@ -84,6 +98,13 @@ public void tallenna(String hakem) throws SailoException {
public
static
void
main
(
String
[]
args
)
throws
SailoException
{
Suoritukset
suoritukset
=
new
Suoritukset
();
try
{
suoritukset
.
lueTiedostosta
(
"suoritukset"
);
}
catch
(
SailoException
ex
)
{
System
.
err
.
println
(
ex
.
getMessage
());
}
Suoritus
eka
=
new
Suoritus
();
Suoritus
toka
=
new
Suoritus
();
eka
.
rekisteroi
();
...
...
This diff is collapsed.
Click to expand it.
src/reittiLoki/Suoritus.java
+
28
−
2
View file @
d4e75d51
...
...
@@ -2,6 +2,8 @@ package reittiLoki;
import
java.io.PrintStream
;
import
fi.jyu.mit.ohj2.Mjonot
;
/**
* @author OMISTAJA
* @version 28.2.2025
...
...
@@ -100,6 +102,15 @@ public class Suoritus {
public
String
getNimi
()
{
return
this
.
nimi
;
}
/**
* Asettaa halutun id:n suoritukselle.
* @param nro asetettava id
*/
private
void
setId
(
int
nro
)
{
id
=
nro
;
if
(
id
>=
seuraavaNro
)
seuraavaNro
=
id
+
1
;
}
/**
* Muuntaa Suorituksen tiedot merkkijonoksi.
...
...
@@ -115,8 +126,23 @@ public class Suoritus {
suoritusPvm
+
"|"
+
yrityksia
+
"|"
+
halli
+
"|"
+
kommentti
;
kommentti
;
}
/**
* @param r Tutkittava rivi
*/
public
void
parse
(
String
r
)
{
StringBuilder
sb
=
new
StringBuilder
(
r
);
setId
(
Mjonot
.
erota
(
sb
,
'|'
,
getId
()));
nimi
=
Mjonot
.
erota
(
sb
,
'|'
,
nimi
);
vaikeusAste
=
Mjonot
.
erota
(
sb
,
'|'
,
vaikeusAste
);
kiipeilyTyyli
=
Mjonot
.
erota
(
sb
,
'|'
,
kiipeilyTyyli
);
reitinTyyppi
=
Mjonot
.
erota
(
sb
,
'|'
,
reitinTyyppi
);
suoritusPvm
=
Mjonot
.
erota
(
sb
,
'|'
,
suoritusPvm
);
yrityksia
=
Mjonot
.
erota
(
sb
,
'|'
,
yrityksia
);
halli
=
Mjonot
.
erota
(
sb
,
'|'
,
halli
);
kommentti
=
Mjonot
.
erota
(
sb
,
'|'
,
kommentti
);
}
...
...
This diff is collapsed.
Click to expand it.
suoritukset/suoritukset.dat
+
3
−
1
View file @
d4e75d51
1||||||0||
2||||||0||
222||||||0||
223||||||0||
224||||||0||
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