Skip to content

Task Class Python #53

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

Open
wants to merge 1 commit into
base: Grigorev_Aleksandr_Konstantinovich
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
#def summ(a: int, b: int) -> int:
# return a + b


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

from phonenumber.phone import Phone

def main():
phone1 = Phone("Iphone", "Black", 9834765873)
print("Brand:", phone1.get_brand())
print("Color:", phone1.get_color())
print("Number", phone1.get_number(), "\n")

phone2 = Phone("OnePlus", "Gold", 2873469126)
print("Brand:", phone2.get_brand())
print("Color:", phone2.get_color())
print("Number", phone2.get_number(), "\n")

phone3 = Phone("POCO", "Blue", 1265872364)
print("Brand:", phone3.get_brand())
print("Color:", phone3.get_color())
print("Number", phone3.get_number(), "\n")

if __name__ == "__main__":
print("Hello world")
print(summ(3, 4))
main()
25 changes: 25 additions & 0 deletions python/src/phonenumber/phone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Phone:
def __init__(self, brand_name, color, number):
self.brand = brand_name
self.color = color
self.number = 0
self.set_number(number)

def set_number(self, phone_number):
if 999999999 < phone_number < 10000000000:
self.number = phone_number
else:
raise ValueError("Неправильно набран номер")

def get_number(self):
return self.number

def set_color(self, phone_color):
self.color = phone_color

def get_color(self):
return self.color

def get_brand(self):
return self.brand