Create a class named `Plane` that implements the functionality of an airline reservation system. Write an application that utilizes the `Plane` class to test its capabilities. Include a method within the `Plane` class named `CheckIn()` to manage the check-in process. This method should prompt the user to enter `1` to select a First-Class seat or `2` to select an Economy seat.

Answered on

To create a simple airline reservation system, you can start by defining a `Plane` class. Below is a basic implementation of such a class in Python. Note that, for the sake of simplicity, this example does not include error checking or persistence of data between runs.

```python class Plane: def __init__(self): # Initialize seats self.first_class_seats = [False] * 5 # Assuming there are 5 first-class seats self.economy_seats = [False] * 30 # Assuming there are 30 economy seats

def check_in(self): seat_type = input("Enter '1' for First-Class or '2' for Economy: ") if seat_type == "1": self.assign_seat(self.first_class_seats, "First-Class") elif seat_type == "2": self.assign_seat(self.economy_seats, "Economy") else: print("Invalid input. Please enter '1' or '2'.")

def assign_seat(self, seats, seat_type): for index, taken in enumerate(seats): if not taken: seats[index] = True print(f"{seat_type} seat assigned: Seat {index + 1}") return print(f"No more seats available in {seat_type}.")

# Application to test the `Plane` class def main(): plane = Plane() while True: plane.check_in() another_booking = input("Would you like to book another seat? (yes/no): ") if another_booking.lower() != 'yes': break

if __name__ == "__main__": main() ```

The `Plane` class has two lists to represent first-class and economy seats. The `check_in` method prompts the user to choose between first-class and economy and assigns a seat based on their choice.

To run the application, you would simply execute the `main()` function, which creates an instance of the `Plane` class and repeatedly calls its `check_in` method until the user decides to stop booking.

Extra: When writing a program that simulates an airline reservation system, you would typically consider the following concepts:

1. Data representation: How to represent seats in different sections of the plane. 2. User input: How to interact with the user to get their preferences. 3. Business logic: Implementing the rules of the reservation system (e.g., you cannot assign a seat that is already taken). 4. User feedback: Informing the user of the actions that the system is taking or any issues with their input.

The simple example provided above demonstrates these concepts at a basic level. In a real-world application, you would likely need a more complex system that deals with more details, such as personal details of passengers, persistence of data (saving the state of the reservation system between runs), and possibly a graphical user interface (GUI) or web interface for easier use.