Last active
October 24, 2023 08:43
-
-
Save trikitrok/8d317a53021799b64e470c269775f203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// As a direct chain of calls | |
class FlightBooking { | |
private Plane plane; | |
// ... | |
public boolean isSeatAvailable(int rowNumber, String seat) { | |
return plane.getRows().get(rowNumber - 1).isAvailable(seat); | |
} | |
} | |
// Chaining calls through intermediate results | |
class FlightBooking { | |
private Plane plane; | |
// ... | |
public boolean isSeatAvailable(int rowNumber, String seat) { | |
List>Row> rows = plane.getRows(); | |
Row row = rows.get(rowNumber - 1); | |
return row.isAvailable(seat); | |
} | |
} | |
//---------------------------------------------------------------------------- | |
//---------------------------------------------------------------------------- | |
class FlightBooking { | |
private Plane plane; | |
// ... | |
public boolean isSeatAvailable(int rowNumber, String seat) { | |
return plane.hasAvailableSeatAt(rowNumber, seat); | |
} | |
} | |
class Plane { | |
Rows rows; | |
// ... | |
public boolean hasAvailableSeatAt(int rowNumber, String seat) { | |
return rows.isAvailable(rowNumber, seat); | |
} | |
} | |
class Rows { | |
List<Row> rows; | |
// ... | |
public boolean isAvailable(int rowNumber, String seat) { | |
Row row = rows.get(rowNumber - 1); | |
return row.isAvailable(seat); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment