Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

laba1py #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed python/src/__init__.py
Empty file.
51 changes: 51 additions & 0 deletions python/src/car.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class Car:
def __init__(self, speed, weight, name):
self._speed = speed
self.check_speed(speed)
self._weight = weight
self.check_weight(weight)
self._name = name

@property
def speed(self):
return self._speed

@speed.setter
def speed(self, skorost):
self.check_speed(skorost)
self._speed = skorost

@property
def weight(self):
return self._weight

@weight.setter
def weight(self, ves):
self.check_weight(ves)
self._weight = ves

@property
def name(self):
return self._name

@name.setter
def name(self, imya):
self._name = imya

@name.setter
def name(self, imya):
self._name = imya

def check_speed(self, speed):
if speed >= 500 or speed <= 0:
raise ValueError("Чет не так со скоростью")

def check_weight(self, weight):
if weight >= 2000 or weight <= 1000:
raise ValueError("Чет не так с весом")

@property
def mashina(self):
return f"""Скорость: {self.speed}
Вес: {self.weight}
Марка машины: {self.name}"""
8 changes: 3 additions & 5 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
def summ(a: int, b: int) -> int:
return a + b

from car import Car

if __name__ == "__main__":
print("Hello world")
print(summ(3, 4))
car = Car(10000, 1500, "Машына")
print(car.mashina)
Loading