diff --git a/__pycache__/dragon.cpython-311.pyc b/__pycache__/dragon.cpython-311.pyc new file mode 100644 index 0000000..abba173 Binary files /dev/null and b/__pycache__/dragon.cpython-311.pyc differ diff --git a/__pycache__/dragon.cpython-313.pyc b/__pycache__/dragon.cpython-313.pyc new file mode 100644 index 0000000..a313ade Binary files /dev/null and b/__pycache__/dragon.cpython-313.pyc differ diff --git a/__pycache__/hero.cpython-311.pyc b/__pycache__/hero.cpython-311.pyc new file mode 100644 index 0000000..cedc817 Binary files /dev/null and b/__pycache__/hero.cpython-311.pyc differ diff --git a/__pycache__/hero.cpython-313.pyc b/__pycache__/hero.cpython-313.pyc new file mode 100644 index 0000000..36aa2cd Binary files /dev/null and b/__pycache__/hero.cpython-313.pyc differ diff --git a/__pycache__/npc.cpython-311.pyc b/__pycache__/npc.cpython-311.pyc new file mode 100644 index 0000000..657da17 Binary files /dev/null and b/__pycache__/npc.cpython-311.pyc differ diff --git a/__pycache__/npc.cpython-313.pyc b/__pycache__/npc.cpython-313.pyc new file mode 100644 index 0000000..675c19b Binary files /dev/null and b/__pycache__/npc.cpython-313.pyc differ diff --git a/__pycache__/player.cpython-311.pyc b/__pycache__/player.cpython-311.pyc new file mode 100644 index 0000000..a3a338a Binary files /dev/null and b/__pycache__/player.cpython-311.pyc differ diff --git a/__pycache__/player.cpython-313.pyc b/__pycache__/player.cpython-313.pyc new file mode 100644 index 0000000..4b9104a Binary files /dev/null and b/__pycache__/player.cpython-313.pyc differ diff --git a/__pycache__/skeleton.cpython-311.pyc b/__pycache__/skeleton.cpython-311.pyc new file mode 100644 index 0000000..73fbf09 Binary files /dev/null and b/__pycache__/skeleton.cpython-311.pyc differ diff --git a/__pycache__/skeleton.cpython-313.pyc b/__pycache__/skeleton.cpython-313.pyc new file mode 100644 index 0000000..e88e9d3 Binary files /dev/null and b/__pycache__/skeleton.cpython-313.pyc differ diff --git a/dragon.py b/dragon.py new file mode 100644 index 0000000..bf35873 --- /dev/null +++ b/dragon.py @@ -0,0 +1,12 @@ +# import time +# from hero import Hero + + +class Dragon: + + def __init__(self, dragon_name): + self.dragon_name = dragon_name + self.dragon_hp = 5000 + self.dragon_dm = 100 + self.hl = 300 + diff --git a/hero.py b/hero.py new file mode 100644 index 0000000..520ec10 --- /dev/null +++ b/hero.py @@ -0,0 +1,120 @@ +import time +import random as rd + +class Hero: + + def __init__(self, name): + self.name = name + self.hero_hp = 15000 + self.hero1_hp = 15000 + self.kills_count_with_dragon = 0 + self.deaths_count_with_dragon = 0 + self.kills_count_with_skelet = 0 + self.deaths_count_with_skelet = 0 + + + def attack_with_dragon(self, npc, dragon): + + while npc.npc_hp > 0 and self.hero_hp > 0: + time.sleep(1) + hero_damage = rd.randrange(100, 500, 50) + dragon.dragon_dm + npc.npc_hp -= hero_damage + print(f'{self.name} и {dragon.dragon_name} атакуют {npc.npc}!') + print(f'Здоровье врага: {npc.npc_hp + hero_damage} - {hero_damage} = {npc.npc_hp}') + + if npc.npc_hp <= 0: + self.kills_count_with_dragon += 1 + print('Твой герой одержал победу!') + break + + npc_damage = npc.npc_dm + self.hero_hp -= npc_damage + print(f'\t {npc.npc} атакует {self.name}!') + print(f'\t Здоровье героя: {self.hero_hp + npc_damage} - {npc_damage} = {self.hero_hp}') + + if self.hero_hp <= 0: + self.deaths_count_with_dragon += 1 + print('Герой погиб!') + break + + + + def attack_with_skeleton(self, npc, skeleton): + + while npc.npc_hp > 0 and self.hero_hp > 0: + time.sleep(1) + hero_damage = rd.randrange(100, 500, 50) + skeleton.skelet_dm + npc.npc_hp -= hero_damage + print(f'{self.name} и {skeleton.skelet_name} атакуют {npc.npc}!') + print(f'Здоровье врага: {npc.npc_hp + hero_damage} - {hero_damage} = {npc.npc_hp}') + + if npc.npc_hp <= 0: + self.kills_count_with_skelet += 1 + print('Твой герой одержал победу!') + break + + npc_damage = npc.npc_dm + self.hero_hp -= npc_damage + print(f'\t {npc.npc} атакует {self.name}!') + print(f'\t Здоровье героя: {self.hero_hp + npc_damage} - {npc_damage} = {self.hero_hp}') + + if self.hero_hp <= 0: + self.deaths_count_with_skelet += 1 + print('Герой погиб!') + break + + + def healing(self, dragon): + + if self.hero_hp < 15000: + while self.hero_hp < 15000: + time.sleep(1) + self.hero_hp += dragon.hl + self.hero1_hp = self.hero_hp + print(f'Герой восстанавливает здоровье: {self.hero_hp - dragon.hl} + {dragon.hl} = {self.hero_hp}') + + if self.hero_hp >= 15000: + + if self.hero_hp > 15000: + self.hero_hp = 15000 + self.hero1_hp = 15000 + print(f'Герой восстановил здоровье: {self.hero1_hp}') + break + + elif self.hero_hp == 15000 or self.hero_hp > 15000: + print('Герой не нуждается в лечении') + self.hero_hp = 15000 + self.hero1_hp = 15000 + + + def revival(self): + + if self.hero_hp <= 0: + self.hero_hp = 15000 + self.hero1_hp = self.hero_hp + print('Герой возродился!') + + elif self.hero_hp > 0 and self.hero_hp < 15000: + print('Ваш герой жив, но нуждается в восстановлении здоровья') + + elif self.hero_hp == 15000: + print('Ваш герой жив') + + + def go_outside(self): + print('Ты снаружи') + + + def go_in_castle(self): + print('Ты в замке') + + + def check_hero_statistics(self, dragon, skeleton): + print('________Статистика Героя________') + print(f'Hero: {self.name}') + print(f'\t Health: {self.hero1_hp}') + print(f'\t Monsters: {dragon.dragon_name}, {skeleton.skelet_name}') + print(f'\t Kills: {self.kills_count_with_dragon + self.kills_count_with_skelet}') + print(f'\t Deaths: {self.deaths_count_with_dragon + self.deaths_count_with_skelet}') + print('________________________________') + \ No newline at end of file diff --git a/lec_create_class.py b/lec_create_class.py new file mode 100644 index 0000000..eb43fa0 --- /dev/null +++ b/lec_create_class.py @@ -0,0 +1,8 @@ + +class Ball: + pass +obj1=Ball() +ball_1=Ball() +ball_2=Ball() +print(dir (ball_1)) +print(dir(int)) diff --git a/lec_dinamic_fils.py b/lec_dinamic_fils.py new file mode 100644 index 0000000..1be72ed --- /dev/null +++ b/lec_dinamic_fils.py @@ -0,0 +1,11 @@ +class Ball: + def __init__(self, mass): + + self.mass=mass + self.image='hexagone' + +ball=Ball(0.5) +print(ball.image) +print(ball.mass) +ball.image='lines' +print(ball.image) \ No newline at end of file diff --git a/lec_init.py b/lec_init.py new file mode 100644 index 0000000..250bbe3 --- /dev/null +++ b/lec_init.py @@ -0,0 +1,5 @@ +class Ball: + def __init__(self): + print('я вызвался') +ball=Ball() +ball2=Ball() \ No newline at end of file diff --git a/lec_static_fils.py b/lec_static_fils.py new file mode 100644 index 0000000..0db254d --- /dev/null +++ b/lec_static_fils.py @@ -0,0 +1,18 @@ +class Ball: + color='red' + radius=5 + +ball=Ball() +print(ball.color) +print(Ball.radius) + +ball.color='white' +print(ball.color) +print(Ball.color) +Ball.color='white' +new_ball=Ball() +print(Ball.color) +print(new_ball.color) +new_ball.radius=10 +print(new_ball.radius) +print(ball.radius) \ No newline at end of file diff --git a/lec_user_metods.py b/lec_user_metods.py new file mode 100644 index 0000000..23aaae8 --- /dev/null +++ b/lec_user_metods.py @@ -0,0 +1,33 @@ +class Ball: + + def __init__(self,mass): + + self.mass=mass + self.image='hexagone' + self.x=0 + self.y=0 + def drop(self): + print('я подбросился') + self.y=2 + + def kick(self): + print('я пнулся') + self.x += 1 + + def fail(self): + self.mass=self.mass-0.1 + +ball=Ball(0.5) +ball.drop() +ball.kick() +ball.fail() +print(ball.x) +print(ball.mass) +ball.kick() +ball.kick() +ball.kick() +ball.kick() +ball.kick() +ball.kick() +ball.kick() +print(ball.x) \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..bf61da0 --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +import time +from dragon import Dragon +from hero import Hero +from skeleton import Skeleton +from npc import NPC +from player import Player + +pl = Player('red', 'Matvey_pro') +hero = Hero('Makanchik') +dragon1 = Dragon('Leviathan') +skelet1 = Skeleton('Varior') +npc = NPC('Hog Rider') + +npc1 = NPC('Hog Rider') + +npc2 = NPC('Hog Rider 2') + +hero.go_in_castle() +hero.go_outside() +hero.healing(dragon1) +hero.attack_with_dragon(npc1, dragon1) +hero.healing(dragon1) +hero.attack_with_skeleton(npc2, skelet1) + +hero.revival() +hero.check_hero_statistics(dragon1, skelet1) diff --git a/npc.py b/npc.py new file mode 100644 index 0000000..900c850 --- /dev/null +++ b/npc.py @@ -0,0 +1,10 @@ +class NPC: + + def __init__(self, npc): + self.npc = npc + self.npc_hp = 15000 + self.npc_dm = 300 + + + + \ No newline at end of file diff --git a/player.py b/player.py new file mode 100644 index 0000000..4b92c9f --- /dev/null +++ b/player.py @@ -0,0 +1,6 @@ +class Player: + + def __init__(self, color, nik): + self.color = color + self.nik = nik + diff --git a/skeleton.py b/skeleton.py new file mode 100644 index 0000000..1a9379a --- /dev/null +++ b/skeleton.py @@ -0,0 +1,6 @@ +class Skeleton: + + def __init__(self, skelet_name): + self.skelet_name = skelet_name + self.skelet_hp = 7000 + self.skelet_dm = 200 \ No newline at end of file diff --git a/task_1_oop.py b/task_1_oop.py new file mode 100644 index 0000000..71095fe --- /dev/null +++ b/task_1_oop.py @@ -0,0 +1,70 @@ +class Journal: + + def __init__(self, klass): + self.klass = klass + self.stud_list = {} + + + def add_student(self, students): + for i in range(len(students)): + + self.stud_list[students[i]] = {} + + + def add_subjects(self, subject): + self.subject = subject + + for student in self.stud_list: + self.stud_list[student][subject] = [] + + + def rate_students(self, fio, subject, mark): + self.stud_list[fio][subject].append(mark) + + + def print_statistics(self, fio, subject): + print(self.stud_list[fio][subject]) + + + def print_middle(self, fio, subject): + print(round(sum(self.stud_list[fio][subject]) / len(self.stud_list[fio][subject]), 2)) + + + def test(self): + print(self.stud_list) + + +clas1 = Journal('10-И') +clas1.add_student(['Петр', 'Макан Маканов', 'Антон']) +clas1.add_subjects('Информатика') +clas1.add_subjects('Физика') + +clas1.rate_students('Петр', 'Физика', 5) +clas1.rate_students('Петр', 'Физика', 4) +clas1.rate_students('Петр', 'Физика', 3) +clas1.rate_students('Петр', 'Информатика', 1) +clas1.rate_students('Петр', 'Физика', 5) +clas1.rate_students('Петр', 'Физика', 2) +clas1.rate_students('Петр', 'Физика', 2) +clas1.rate_students('Петр', 'Информатика', 5) +clas1.rate_students('Петр', 'Физика', 4) + +clas1.print_statistics('Петр', 'Информатика') +clas1.print_middle('Петр', 'Информатика') + +clas1.print_statistics('Петр', 'Физика') +clas1.print_middle('Петр', 'Физика') + +clas1.test() + + + + + + + + + + + + \ No newline at end of file diff --git a/task_2_oop.py b/task_2_oop.py new file mode 100644 index 0000000..0c2327f --- /dev/null +++ b/task_2_oop.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +""" +Created on Fri Nov 7 18:40:29 2025 + +@author: 123 +""" + diff --git a/task_3_oop.py b/task_3_oop.py new file mode 100644 index 0000000..90a428e --- /dev/null +++ b/task_3_oop.py @@ -0,0 +1,99 @@ +class Puppy: + + states = ['Болеет', 'Выздоравливает', 'Здоров'] + + def __init__(self, index): + self.index = index + self.states = ['Болеет', 'Выздоравливает', 'Здоров'] + self.state = self.states[0] + + def get_treatment(self): + c_index = self.states.index(self.state) + if c_index < (self.states) - 1: + self.state = self.states[c_index + 1] + return True + return False + + def is_healthy(self): + return self.state == self.states[2] + + def info(self): + return {'index': self.index, 'state': self.state, 'is_healthy': self.is_healthy()} + + +class Dog: + + def __init__(self, pup_count): + self.puppies = [Puppy(i) for i in range(pup_count)] + + + def heal_all(self): + for puppy in self.pup_count: + self.pup_count[states[2]] = [] + + def all_are_healthy(self): + for puppy in self.pup_count: + if self.pup_count[states[2]]: + return True + else: + return False + + def give_away_all(self): + for puppie in self.pup_count: + if self.pup_count[states[2]]: + pup_count = 0 + + +class Vet: + + def __init__(self, name, plant): + self.name = name + self.plant = plant + + def work(self): + Dog.heal_all + print('Щенки лечатся') + + def care(self): + if Dog.all_are_healthy is True: + Dog.give_away_all() + else: + print('Не все щенки здоровы') + + # def knowledge_base(self): + # print(self.pup_count[state]) + + + + + + + + + + + + + + +dog = Dog(5) +vet = Vet('Makanchik', dog) +pup = Puppy('счастлив') +dog.heal_all() +vet.work() +vet.care() + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/\320\224\320\276\321\201\320\272\320\260 \320\234\320\260\321\202\320\262\320\265\321\217 (1).png" "b/\320\224\320\276\321\201\320\272\320\260 \320\234\320\260\321\202\320\262\320\265\321\217 (1).png" new file mode 100644 index 0000000..73bae5c Binary files /dev/null and "b/\320\224\320\276\321\201\320\272\320\260 \320\234\320\260\321\202\320\262\320\265\321\217 (1).png" differ