Skip to content

Commit

Permalink
[repo] fix nullpointer
Browse files Browse the repository at this point in the history
  • Loading branch information
JPCatarino committed Jun 7, 2020
1 parent 39d464e commit 79d5881
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/main/ClientBusDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ public static void main(String[] args) {
int baseServerPortNumb=33000; // server port number

// Initiate Shared Regions
RepositoryStub repository = new RepositoryStub(baseServerHostName, baseServerPortNumb+1);
ArrivalQuayStub arrivalQuay = new ArrivalQuayStub(baseServerHostName, baseServerPortNumb+3);
DepartureQuayStub departureQuay = new DepartureQuayStub(baseServerHostName, baseServerPortNumb+7);

// Initiate Bus Driver
BusDriver busDriver = new BusDriver(100, arrivalQuay, departureQuay);

//Communicate parameters
repository.probPar(N_passengers, T_seats);
arrivalQuay.probPar(T_seats);

// Join BusDriver
Expand Down
2 changes: 0 additions & 2 deletions src/main/ClientPorter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static void main(String[] args) {
int baseServerPortNumb=33000; // server port number

// Initiate Shared Regions
RepositoryStub repository = new RepositoryStub(baseServerHostName, baseServerPortNumb+1);
ArrivalLoungeStub arrivalLounge = new ArrivalLoungeStub(baseServerHostName, baseServerPortNumb+2);
BagColPointStub bagColPoint = new BagColPointStub(baseServerHostName, baseServerPortNumb+5);
TempStgAreaStub tempStgArea = new TempStgAreaStub(baseServerHostName, baseServerPortNumb+9);
Expand All @@ -27,7 +26,6 @@ public static void main(String[] args) {
Porter porter = new Porter(arrivalLounge, bagColPoint, tempStgArea);

//Communicate parameters
repository.probPar(N_passengers, T_seats);
arrivalLounge.probPar(N_passengers,K_landings);

// Join Porter
Expand Down
10 changes: 6 additions & 4 deletions src/sharedRegions/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public void setN_PASSENGERS(int n_PASSENGERS) {

Arrays.fill(this.ST, "-");
Arrays.fill(this.SI, "-");
reportInitialStatus();
}

/**
Expand Down Expand Up @@ -455,7 +456,9 @@ public String toString() {
* Write the initial State (Calculate logger file name, create logger file and add header to the logger file).
*/
public void reportInitialStatus() {

if(initialized){
return;
}
FileWriter fw;
long count=0;

Expand All @@ -481,6 +484,7 @@ public void reportInitialStatus() {
pw.print(new String(new char[31 + (19 * N_PASSENGERS - 4) / 2 - 34]) + "AIRPORT RHAPSODY - Description of the internal state of the problem\n");
pw.println();
pw.print(header_debug());
fw.close();
}
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -492,9 +496,6 @@ public void reportInitialStatus() {
* Append the current State to the logger file.
*/
public synchronized void reportStatus() {
if(!initialized){
reportInitialStatus();
}
FileWriter fw;
try {
fw = new FileWriter(filename, true);
Expand Down Expand Up @@ -527,5 +528,6 @@ public void finalReport(){
} catch (IOException e) {
e.printStackTrace();
}
initialized = false;
}
}

0 comments on commit 79d5881

Please sign in to comment.