Advertisement
Georgi_Benchev

Untitled

Nov 5th, 2024
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1.  //  RETURNS STRING WITH ALL THE VEHICLES OF THE USER
  2.     @Override
  3.     public String printVehicles() {
  4.         StringBuilder output = new StringBuilder(String.format(USER_HEADER, username));
  5.  
  6.         if (vehicles.isEmpty()) {
  7.             output.append("\n");
  8.             output.append(NO_VEHICLES_HEADER);
  9.         } else {
  10.             for (int i = 0; i < vehicles.size(); i++) {
  11.                 // PRINTING VEHICLE
  12.                 output.append("\n");
  13.                 output.append(i + 1).append(vehicles.get(i).toString());
  14.                 // PRINTING THE COMMENTS OF THE CURRENT VEHICLE
  15.                 if (vehicles.get(i).getComments().isEmpty()) {
  16.                     output.append(NO_COMMENTS_HEADER);
  17.                 } else {
  18.                     output.append(vehicles.get(i).printComments());
  19.                 }
  20.             }
  21.         }
  22.         return output.toString();
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement