Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
k2022
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
tie
ohj2
esimerkit
k2022
Commits
d1393f55
Commit
d1393f55
authored
3 years ago
by
Vesa Lappalainen
Browse files
Options
Downloads
Patches
Plain Diff
rekisteroi
parent
a7f91f17
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
luennot/live13/.classpath
+1
-0
1 addition, 0 deletions
luennot/live13/.classpath
luennot/live13/src/kerho/Jasen.java
+37
-3
37 additions, 3 deletions
luennot/live13/src/kerho/Jasen.java
luennot/live13/src/kerho/test/JasenTest.java
+31
-0
31 additions, 0 deletions
luennot/live13/src/kerho/test/JasenTest.java
with
69 additions
and
3 deletions
luennot/live13/.classpath
+
1
−
0
View file @
d1393f55
...
@@ -7,5 +7,6 @@
...
@@ -7,5 +7,6 @@
</attributes>
</attributes>
</classpathentry>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.USER_LIBRARY/ohj2"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.USER_LIBRARY/ohj2"
/>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.junit.JUNIT_CONTAINER/5"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
<classpathentry
kind=
"output"
path=
"bin"
/>
</classpath>
</classpath>
This diff is collapsed.
Click to expand it.
luennot/live13/src/kerho/Jasen.java
+
37
−
3
View file @
d1393f55
...
@@ -11,7 +11,7 @@ import java.io.PrintStream;
...
@@ -11,7 +11,7 @@ import java.io.PrintStream;
public
class
Jasen
{
public
class
Jasen
{
private
int
tunnusNro
;
private
int
tunnusNro
;
private
String
nimi
=
""
;
private
String
nimi
=
""
;
private
String
hetu
=
""
;
private
String
hetu
=
""
;
private
String
katuosoite
=
""
;
private
String
katuosoite
=
""
;
private
String
postinumero
=
""
;
private
String
postinumero
=
""
;
...
@@ -24,6 +24,8 @@ public class Jasen {
...
@@ -24,6 +24,8 @@ public class Jasen {
private
double
maksu
=
0
;
private
double
maksu
=
0
;
private
String
lisatietoja
=
""
;
private
String
lisatietoja
=
""
;
private
static
int
seuraavaNro
=
1
;
/**
/**
* Alustaa jäsenen tiedot tyhjiksi
* Alustaa jäsenen tiedot tyhjiksi
...
@@ -56,6 +58,38 @@ public class Jasen {
...
@@ -56,6 +58,38 @@ public class Jasen {
}
}
/**
* Antaa jäsenelle seuraavan rekisterinumeron.
* @return jäsenen uusi tunnusNro
* @example
* <pre name="test">
* Jasen aku1 = new Jasen();
* aku1.getTunnusNro() === 0;
* aku1.rekisteroi();
* Jasen aku2 = new Jasen();
* aku2.rekisteroi();
* int n1 = aku1.getTunnusNro();
* int n2 = aku2.getTunnusNro();
* n1 === n2-1;
* </pre>
*/
public
int
rekisteroi
()
{
this
.
tunnusNro
=
seuraavaNro
;
seuraavaNro
++;
return
this
.
tunnusNro
;
}
/**
* Palauttaa jäsenen tunnusnumeron.
* @return jäsenen tunnusnumero
*/
public
int
getTunnusNro
()
{
return
tunnusNro
;
}
/**
/**
* @param args ei käytössä
* @param args ei käytössä
*/
*/
...
@@ -63,8 +97,8 @@ public class Jasen {
...
@@ -63,8 +97,8 @@ public class Jasen {
Jasen
aku
=
new
Jasen
();
Jasen
aku
=
new
Jasen
();
Jasen
aku2
=
new
Jasen
();
Jasen
aku2
=
new
Jasen
();
//
aku.rekisteroi();
aku
.
rekisteroi
();
//
aku2.rekisteroi();
aku2
.
rekisteroi
();
aku
.
tulosta
(
System
.
out
);
aku
.
tulosta
(
System
.
out
);
...
...
This diff is collapsed.
Click to expand it.
luennot/live13/src/kerho/test/JasenTest.java
0 → 100644
+
31
−
0
View file @
d1393f55
package
kerho.test
;
// Generated by ComTest BEGIN
import
static
org
.
junit
.
Assert
.*;
import
org.junit.*
;
import
kerho.*
;
// Generated by ComTest END
/**
* Test class made by ComTest
* @version 2022.02.21 11:09:38 // Generated by ComTest
*
*/
@SuppressWarnings
({
"all"
})
public
class
JasenTest
{
// Generated by ComTest BEGIN
/** testRekisteroi66 */
@Test
public
void
testRekisteroi66
()
{
// Jasen: 66
Jasen
aku1
=
new
Jasen
();
assertEquals
(
"From: Jasen line: 68"
,
0
,
aku1
.
getTunnusNro
());
aku1
.
rekisteroi
();
Jasen
aku2
=
new
Jasen
();
aku2
.
rekisteroi
();
int
n1
=
aku1
.
getTunnusNro
();
int
n2
=
aku2
.
getTunnusNro
();
assertEquals
(
"From: Jasen line: 74"
,
n2
-
1
,
n1
);
}
// Generated by ComTest END
}
\ 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