Route toString() Exception fix:

- toString() throws exception
   when invoked on 'noise' vehicles
   The routes made for them dont have
   District and Mashier set. Accessing
   name() from a null method throws
   null ptr ex.

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2020-12-01 00:23:07 +03:00
parent e28a593280
commit 0b4e259495
Signed by: Hesham
GPG Key ID: 74876157D199B09E

View File

@ -42,10 +42,11 @@ public class Route {
return result;
}
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append(super.toString())
.append("\n").append(String.format("%s:%s",getHotelArea().name(),getMashier().name()))
.append("\n").append(String.format("%s:%s",getHotelArea(),getMashier()))
.append("\n")
.append("Length: ").append(getTotalLength())
.append("\n")