Skip to content
Snippets Groups Projects
Commit d4a0ba0b authored by Grethe Sandstrak's avatar Grethe Sandstrak
Browse files

Replace Land.java

parent 27ded073
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
private String statsoverhode; private String statsoverhode;
private By[] byer; // hovedstad indeks 0 private By[] byer; // hovedstad indeks 0
private int antallbyer = 0; private int antallbyer = 0;
private static final long serialVersionUID = 101;
public Land(String navn, String statsoverhode, int maksAntallByer) { public Land(String navn, String statsoverhode, int maksAntallByer) {
this.navn = navn; this.navn = navn;
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
public void setStatsoverhode(String newValue) {statsoverhode = newValue; } public void setStatsoverhode(String newValue) {statsoverhode = newValue; }
public String toString() { public String toString() {
String res = navn + ", Statsoverhode: " + statsoverhode + "\n Byer:\n---------------------\n"; String res = navn + ", Statsoverhode: " + navn + "\n Byer:\n---------------------\n";
for (By b : byer) { for (By b : byer) {
if (b != null) res += b + "\n"; if (b != null) res += b + "\n";
} }
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
public int getAntallInnbyggere() { public int getAntallInnbyggere() {
int antall = 0; int antall = 0;
for (int i=0; i<antallbyer; i++) { for (int i=0; i<antallbyer; i++) {
antall += byer[i].getAntallInnbyggere(); antall = byer[i].getAntallInnbyggere();
} }
return antall; return antall;
} }
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
} }
return ordfrere; return ordfrere;
} }
public String[] getSortertOrdfrerListe() { public String[] getSortertOrdfrerListe() {
String[] ordfrere = getOrdfrere(); String[] ordfrere = getOrdfrere();
for(int start=0; start<ordfrere.length; start++){ for(int start=0; start<ordfrere.length; start++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment