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

lab6 go -> py #40

Open
wants to merge 1 commit into
base: Hosrovjan_Aleksandr_Armenovich
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
29 changes: 25 additions & 4 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
def summ(a: int, b: int) -> int:
return a + b
from pistol import Pistol


if __name__ == "__main__":
print("Hello world")
print(summ(3, 4))
#print("Hello world")
#print(summ(3, 4))

# Хосровян Александр Арменович 1/279
print("Lab 1 on python:")

pistol1 = Pistol(9, "Desert Eagler", ".357 Magnum")
pistol2 = Pistol(15, "...", "...")

pistol2.set_model("Glock")
pistol1.set_model("Revolver")

pistol1.set_magazine_capacity(6)
pistol2.set_caliber("9х19 Luger")

print("Pistol 1")
print("Модель пистолета - {}".format(pistol1.get_model()))
print("Ёмкость магазина - {}".format(pistol1.get_magazine_capacity()))
print("Калибр - {}".format(pistol1.get_caliber()))

print("Pistol 2")
print("Модель пистолета - {}".format(pistol2.get_model()))
print("Ёмкость магазина - {}".format(pistol2.get_magazine_capacity()))
print("Калибр - {}".format(pistol2.get_caliber()))
27 changes: 27 additions & 0 deletions python/src/pistol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Pistol:
def __init__(self, magazine_capacity: int, model: str, caliber: str):
if magazine_capacity < 5 or magazine_capacity > 30:
raise ValueError("Invalid pistol magazine capacity")
self.magazine_capacity = magazine_capacity
self.model = model
self.caliber = caliber

def set_magazine_capacity(self, magazine_capacity: int):
if magazine_capacity < 5 or magazine_capacity > 30:
raise ValueError("Invalid pistol magazine capacity")
self.magazine_capacity = magazine_capacity

def set_model(self, model: str):
self.model = model

def set_caliber(self, caliber: str):
self.caliber = caliber

def get_magazine_capacity(self) -> int:
return self.magazine_capacity

def get_model(self) -> str:
return self.model

def get_caliber(self) -> str:
return self.caliber