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

8.1 #9

Open
wants to merge 1 commit into
base: Lesson_6
Choose a base branch
from
Open
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
102 changes: 102 additions & 0 deletions task8.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __add__(self, other):
class MyError(Exception):
def __init__(self, txt):
self.txt = txt
"""

a = []
while True:
Expand All @@ -124,9 +125,110 @@ def __init__(self, txt):

print(a)

"""

#####################################################
#4. Начните работу над проектом «Склад оргтехники». Создайте класс, описывающий склад. А также класс «Оргтехника»,
# который будет базовым для классов-наследников. Эти классы — конкретные типы оргтехники (принтер, сканер, ксерокс).
# В базовом классе определить параметры, общие для приведенных типов. В классах-наследниках реализовать параметры,
# уникальные для каждого типа оргтехники.

from datetime import datetime

class Depot:
def __init__(self, title):
self.title = title
self.lists = {}
self.give_lists = {}

def take_to_depot(self, equipment):
# внесение в словарь название оборудования, серийный номер и время передачи на склад
t = datetime.now()
self.lists.update({equipment.serial_number:[equipment.title, self,t]})
print('На склад '+self.title+' получено оборудование:'+ '' +equipment.title+' ,серийный номер - '+ str(equipment.serial_number)+', Дата:'
+ str(t.day)+'.'+str(t.month)+'.'+str(t.year))


def give_to_depot(self, equipment, other):
# передача оборудование на другой склад или подразделение
t = datetime.now()
self.give_lists.update({equipment.serial_number: [equipment.title,other, t]})
print('Передано оборудование:' + '' + equipment.title + ' ,серийный номер - ' + str(
equipment.serial_number) + ', Дата:'
+ str(t.day) + '.' + str(t.month) + '.' + str(t.year))
other.take_to_depot(equipment)


def list_equipments(self):
print('На склад '+self.title + ' получено оборудование:')
print(self.lists)
print('Общее количество: ', len(self.lists))
print('Со склада '+self.title + ' выдано оборудование:')
print(self.give_lists)
print('Общее количество: ', len(self.give_lists))




class Office_equipment:
def __init__(self, title, serial_number):
self.title = title
self.serial_number = serial_number

def __str__(self):
return str(self.title)

class Printer(Office_equipment):
def __init__(self,title,serial_number, print_velocity):
Office_equipment.__init__(self,title, serial_number)
self.print_velocity = print_velocity

def __str__(self):
return 'Название модели:'+Office_equipment.__str__(self) + ' ,Параметры: ' +str(self.print_velocity)


class Scanner(Office_equipment):
def __init__(self, title,serial_number,resolution):
Office_equipment.__init__(self,title, serial_number)
self.resolution = resolution

def __str__(self):
return 'Название модели:'+Office_equipment.__str__(self) + ' ,Параметры: ' +str(self.resolution)

class Copier(Office_equipment):
def __init__(self, title,serial_number, addit):
Office_equipment.__init__(self, title, serial_number)
self.addit = addit

def __str__(self):
return 'Название модели:'+Office_equipment.__str__(self) + ' ,Параметры: ' +str(self.addit)



store1 = Depot('Main warehouse')
store2 = Depot('Small warehouse')
a = Printer('HP',345678,100)
b = Scanner('Epson',123456,4000)
c = Copier('Brother',987654, 50)
d = Printer('HP',245678,200)

print(a)
print(b)
print(c)

store1.take_to_depot(a)
store1.take_to_depot(b)
store1.take_to_depot(c)
store1.take_to_depot(d)

store1.give_to_depot(a,store2)

store1.list_equipments()
store2.list_equipments()


#######################################
# Продолжить работу над первым заданием. Разработать методы, отвечающие за приём оргтехники на склад и передачу
# в определенное подразделение компании. Для хранения данных о наименовании и количестве единиц оргтехники,
# а также других данных, можно использовать любую подходящую структуру, например словарь.