Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Grethe Sandstrak
SU1_Workshop_testing_2017
Commits
16f62e61
Commit
16f62e61
authored
Feb 07, 2018
by
Grethe Sandstrak
Browse files
Upload New File
parent
d4a0ba0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
kodeforst/junit_tester/By.java
0 → 100644
View file @
16f62e61
class
By
implements
java
.
io
.
Serializable
{
private
String
navn
;
private
String
ordfrer
;
private
int
antallInnbyggere
;
private
int
maksAntallInnbyggere
=
1000
;
private
static
final
long
serialVersionUID
=
101
;
public
By
(
String
navn
,
String
ordfrer
,
int
antallInnbyggere
,
int
maksAntallInnbyggere
)
throws
Exception
{
this
.
navn
=
navn
;
this
.
ordfrer
=
ordfrer
;
if
(
antallInnbyggere
<=
maksAntallInnbyggere
){
this
.
antallInnbyggere
=
antallInnbyggere
;
this
.
maksAntallInnbyggere
=
maksAntallInnbyggere
;
}
else
throw
new
Exception
(
"Byen kan ikke ha flere innbyggere enn det er plass til!"
);
}
public
By
(){}
public
String
getNavn
(){
return
navn
;
}
public
void
setNavn
(
String
newValue
)
{
navn
=
newValue
;
}
public
String
getOrdfrer
(){
return
ordfrer
;
}
public
void
setOrdfrer
(
String
newValue
)
{
ordfrer
=
newValue
;
}
public
int
getAntallInnbyggere
(){
return
antallInnbyggere
;}
public
void
setAntallInnbyggere
(
int
newValue
){
antallInnbyggere
=
newValue
;}
public
int
getMaksAntallInnbyggere
(){
return
maksAntallInnbyggere
;}
public
void
setMaksAntallInnbyggere
(
int
newValue
){
maksAntallInnbyggere
=
newValue
;}
public
String
toString
()
{
return
navn
+
" "
+
ordfrer
+
" "
+
antallInnbyggere
+
" "
+
maksAntallInnbyggere
;
}
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
instanceof
By
)
{
By
by
=
(
By
)
obj
;
if
(
by
.
getNavn
().
equals
(
navn
))
return
true
;
}
return
false
;
}
public
int
getLedigKapasitet
(){
return
maksAntallInnbyggere
-
antallInnbyggere
;}
public
boolean
ledig
(){
return
(
antallInnbyggere
<=
maksAntallInnbyggere
);}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment