Refactoring Aircraft

Let's return to our Aircraft class:

class Aircraft:    def __init__(self, registration, model, num_rows,                  num_seats_per_row):        self._registration = registration        self._model = model        self._num_rows = num_rows        self._num_seats_per_row = num_seats_per_row    def registration(self):        return self._registration    def model(self):        return self._model    def seating_plan(self):        return (range(1, self._num_rows + 1),                "ABCDEFGHJK"[:self._num_seats_per_row])

The design of this class is somewhat flawed, in that objects instantiated using it depend on being supplied with a seating configuration that matches the aircraft model. For the purposes of this exercise we can assume that the seating arrangement is fixed per aircraft model.

Better, and simpler, ...

Get The Python Apprentice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.