From 4cb25079ea95cad91dab18d172691cd4f93ffd5e Mon Sep 17 00:00:00 2001 From: rusafob <147656000+rusafob@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:21:17 +0300 Subject: [PATCH 1/3] main.py --- python/src/main.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/python/src/main.py b/python/src/main.py index e37a77c..fed35c9 100644 --- a/python/src/main.py +++ b/python/src/main.py @@ -1,7 +1,5 @@ -def summ(a: int, b: int) -> int: - return a + b - +import __init__ if __name__ == "__main__": - print("Hello world") - print(summ(3, 4)) + gun1 = __init__.Cat("Colt", 9, "Steel") + gun1.vivod() From fcc72b1a03390471a45dcac494a1213cd9e0d8d6 Mon Sep 17 00:00:00 2001 From: rusafob <147656000+rusafob@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:21:47 +0300 Subject: [PATCH 2/3] test_main.py --- python/tests/test_main.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/python/tests/test_main.py b/python/tests/test_main.py index 0280a2e..8b13789 100644 --- a/python/tests/test_main.py +++ b/python/tests/test_main.py @@ -1,37 +1 @@ -import unittest -from src import main - -class SummTests(unittest.TestCase): - - def test_positive(self): - res = main.summ(2, 3) - self.assertEqual(5, res) - - def test_zero(self): - res = main.summ(0, 0) - self.assertEqual(0, res) - - def test_one_negative(self): - res = main.summ(-2, 3) - self.assertEqual(1, res) - - def test_both_negative(self): - res = main.summ(-2, -4) - self.assertEqual(-6, res) - - def test_one_negative_zero_res(self): - res = main.summ(-2, 2) - self.assertEqual(0, res) - - def test_one_negative_and_text(self): - try: - main.summ(-2, "2") - except: - self.assertTrue(True) - return - self.fail() - - -if __name__ == '__main__': - unittest.main() From 4d4f958924d9697da79e352d78f930679c0a1881 Mon Sep 17 00:00:00 2001 From: rusafob <147656000+rusafob@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:22:38 +0300 Subject: [PATCH 3/3] __init__.py --- python/src/__init__.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/python/src/__init__.py b/python/src/__init__.py index e69de29..4fea551 100644 --- a/python/src/__init__.py +++ b/python/src/__init__.py @@ -0,0 +1,42 @@ +class Gun: + def __init__(self, name: str, caliber: float, material: str): + self.__name = name + self.__caliber = caliber + self.__material = material + self.check_caliber(caliber) + + def check_caliber(self, caliber: float): + if caliber <= 0: + print("Некорректный калибр пистолета!") + else: + self.__caliber = caliber + + + def name(self): + return self.__name + + + def name(self, n: str): + self.__name = n + + + def caliber(self): + return self.__caliber + + + def caliber(self, c: float): + self.check_caliber(c) + self.__caliber = c + + + def material(self): + return self.__material + + @material.setter + def material(self, m: str): + self.__material = m + + def vivod(self): + print(f"Название пистолета - {self.__name}") + print(f"Калибр пистолета - {self.__caliber}") + print(f"Материал пистолета - {self.__material}")