Zasadniczy wsad inicjalizacyjny.
This commit is contained in:
113
src/main/java/pl/wat/ms4ds/terenfunkcje/LukDrogowy.java
Normal file
113
src/main/java/pl/wat/ms4ds/terenfunkcje/LukDrogowy.java
Normal file
@@ -0,0 +1,113 @@
|
||||
package pl.wat.ms4ds.terenfunkcje;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class LukDrogowy {
|
||||
|
||||
private WezelDrogowy[] wezly = new WezelDrogowy[2];
|
||||
int id = -1;
|
||||
int dlugosc = 0;
|
||||
int szerokosc = 0;
|
||||
int rodzajNawierzchni = 0;
|
||||
boolean jestMostem = false;
|
||||
|
||||
LukDrogowy() {}
|
||||
|
||||
LukDrogowy(String opis) {
|
||||
if (null == opis || opis.length() == 0){
|
||||
SiecDrogowa.logger.debug("Pusty ciag opis w konstruktorze Luku Drogowego.");
|
||||
return;
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(opis, " \t");
|
||||
String[] tokenTable = new String[st.countTokens()];
|
||||
for (int i = 0; st.hasMoreTokens(); i++) {
|
||||
tokenTable[i] = st.nextToken();
|
||||
}
|
||||
if (tokenTable.length == 6) {
|
||||
try {
|
||||
int id = Integer.parseInt(tokenTable[0]);
|
||||
WezelDrogowy wezel = SiecDrogowa.instancja.wezly.get(id);
|
||||
if (null == wezel)
|
||||
SiecDrogowa.logger.warn("Brak wierzcholka (1) poczatkowego luku. [" + opis + "].");
|
||||
this.getWezly()[0] = wezel;
|
||||
wezel.luki.add(this);
|
||||
} catch (NumberFormatException e) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [Wezel 1].");
|
||||
}
|
||||
try {
|
||||
int id = Integer.parseInt(tokenTable[1]);
|
||||
WezelDrogowy wezel = SiecDrogowa.instancja.wezly.get(id);
|
||||
if (null == wezel)
|
||||
SiecDrogowa.logger.warn("Brak wierzcholka (2) koncowego luku. [" + opis + "].");
|
||||
this.getWezly()[1] = wezel;
|
||||
wezel.luki.add(this);
|
||||
} catch (NumberFormatException e) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [Wezel 2].");
|
||||
}
|
||||
if (this.wezly[0].id == this.wezly[1].id) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [wezly sa identyczne].");
|
||||
}
|
||||
if (GridCoord.czyIdentyczne(this.wezly[0].idKw, this.wezly[1].idKw)) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [wezly sa identyczne].");
|
||||
}
|
||||
try {
|
||||
this.dlugosc = Integer.parseInt(tokenTable[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [Dlugosc].");
|
||||
}
|
||||
try {
|
||||
this.szerokosc = Integer.parseInt(tokenTable[3]);
|
||||
} catch (NumberFormatException e) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [Szerokosc].");
|
||||
}
|
||||
try {
|
||||
this.rodzajNawierzchni = Integer.parseInt(tokenTable[4]);
|
||||
} catch (NumberFormatException e) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [RodzajNawierzchni].");
|
||||
}
|
||||
try {
|
||||
int b = Integer.parseInt(tokenTable[5]);
|
||||
this.jestMostem = (b != 0);
|
||||
} catch (NumberFormatException e) {
|
||||
SiecDrogowa.logger.warn("Bledne dane w pliku z lukami [CzyJestMost].");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getDlugosc() {
|
||||
return dlugosc;
|
||||
}
|
||||
|
||||
public void setDlugosc(int dlugosc) {
|
||||
this.dlugosc = dlugosc;
|
||||
}
|
||||
|
||||
public int getSzerokosc() {
|
||||
return szerokosc;
|
||||
}
|
||||
|
||||
public void setSzerokosc(int szerokosc) {
|
||||
this.szerokosc = szerokosc;
|
||||
}
|
||||
|
||||
public int getRodzajNawierzchni() {
|
||||
return rodzajNawierzchni;
|
||||
}
|
||||
|
||||
public void setRodzajNawierzchni(int rodzajNawierzchni) {
|
||||
this.rodzajNawierzchni = rodzajNawierzchni;
|
||||
}
|
||||
|
||||
public boolean isJestMostem() {
|
||||
return jestMostem;
|
||||
}
|
||||
|
||||
public void setJestMostem(boolean jestMostem) {
|
||||
this.jestMostem = jestMostem;
|
||||
}
|
||||
|
||||
public WezelDrogowy[] getWezly() {
|
||||
return wezly;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user