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
94c0793e
Commit
94c0793e
authored
2 weeks ago
by
Hiltunen Markus Petteri
Browse files
Options
Downloads
Patches
Plain Diff
Aloitetaan Halli luokka.
parent
2348dde9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/reittiLoki/Halli.java
+104
-0
104 additions, 0 deletions
src/reittiLoki/Halli.java
with
104 additions
and
0 deletions
src/reittiLoki/Halli.java
0 → 100644
+
104
−
0
View file @
94c0793e
package
reittiLoki
;
import
java.io.PrintStream
;
/**
* @author OMISTAJA
* @version 1.4.2025
*
*/
public
class
Halli
{
private
int
id
=
0
;
String
nimi
=
""
;
int
suoritusNro
;
private
static
int
seuraavaNro
=
1
;
/**
* Alustaa Suorituksen tiedot.
*/
public
Halli
()
{
//
}
/**
* Tulostetaan suorituksen tiedot
* @param out Minne tulostetaan.
*/
public
void
tulosta
(
PrintStream
out
)
{
out
.
println
(
"Id:"
+
id
+
" \n"
+
"Halli: "
+
nimi
+
" \n"
+
"linkitetty suoritus: "
+
suoritusNro
);
out
.
println
();
}
/**
* Palauttaa suorituksen Id:n.
* @return Suorituksen Id.
*/
public
int
getId
()
{
return
id
;
}
/**
* Aliohjelma antaa suoritukselle seuraavan id:n.
* @example
* <pre name="test">
* Suoritus testi1 = new Suoritus();
* testi1.getId() === 0;
* testi1.rekisteroi();
* Suoritus testi2 = new Suoritus();
* testi2.rekisteroi();
* int n1 = testi1.getId();
* int n2 = testi2.getId();
* n1 === n2-1;
* </pre>
*/
public
void
rekisteroi
()
{
this
.
id
=
seuraavaNro
;
seuraavaNro
++;
}
/**
* Apumetodi, jolla täytetään tiedot suoritukselle. Käytetään kehitysvaiheessa.
* Poistetaan myöhemmin.
* @param suoritus Sen suorituksen ID-numero johon halli liitetään.
*/
public
void
taytaHalli
(
int
suoritus
)
{
nimi
=
"Ristikko "
+
tarkistusNro
();
this
.
suoritusNro
=
suoritus
;
}
/**
* Tarkistusnumeroa käytetään vain varmistamaan että suoritukset eroavat toisistaan. Poistetaan kehityksen jälkeen tarvittaessa.
* @return Tarkistusnumero
*/
public
int
tarkistusNro
()
{
double
nro
=
Math
.
random
()
*
100
;
int
tulos
=
(
int
)
nro
;
return
tulos
;
}
/**
* @return palauttaa suorituksen nimen.
*/
public
String
getNimi
()
{
return
this
.
nimi
;
}
/**
* @param args ei käytössä.
*/
public
static
void
main
(
String
[]
args
)
{
Halli
kala
=
new
Halli
();
kala
.
taytaHalli
(
1
);
kala
.
tulosta
(
System
.
out
);
}
}
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