Is there a way of leaving a space where it is necessary when invoking getClass().getSimpleName().toLowerCase()
method?
For instance, I have several different classes whose names are PublicTransportation
, CityBus
, Metro
, Tram
, Ferry
, Aircraft
.
I have defined my toString()
methods but would like to leave a space between Public
and Transportation
. Same thing for the CityBus
class. Here are my toString()
methods:
//PublicTransportation class
public String toString()
{
return "This " + getClass().getSimpleName().toLowerCase() + " costs " + getTicketPrice() + ". It has " + getNumOfStops() + " number of stops.";
}
//CityBus class
public String toString()
{
return super.toString() + " It's route number is " + getRouteNum()
+ ".\nIt's operation start year is " + getBeginOpYear() + ". The line name is " + getLineName() + ". The driver is "
+ getDriverName() + ".";
}