Advertisement
Andrey_06

Untitled

Feb 8th, 2025
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. class Car:
  2.     def __init__(self, brand, model, year):
  3.         self._brand = brand
  4.         self._model = model
  5.         self._year = year
  6.  
  7.     def get_info(self):
  8.         return f"The car is made by {self._brand}, its model is {self._model} and it was made in {self._year}"
  9.  
  10.     def change_production_year(self, new_year):
  11.         self._year = new_year
  12.         return f"The production year of {self._brand} {self._model} was changed to {self._year}"
  13.  
  14.        
  15. car_1 = Car('Mercedes', 'S-class', '2024')
  16. car_2 = Car('Audi', 'RS7', '2024')
  17.  
  18. print(car_1.get_info())
  19. print(car_2.change_production_year(2025))
  20.  
Tags: #oop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement