1. 흥미로운 클래스 예제

(1) 게임 캐릭터 생성

학생들이 좋아하는 게임을 예로 들어 캐릭터를 만들어볼 수 있습니다.


class GameCharacter:
    def __init__(self, name, job, level=1):
        self.name = name
        self.job = job
        self.level = level
        self.hp = 100

    def level_up(self):
        self.level += 1
        self.hp += 10
        return f"{self.name} has leveled up to {self.level}! HP is now {self.hp}."

# 예시 실행
character = GameCharacter("Aiden", "Wizard")
print(character.level_up())

확장 가능성: 아이템 추가, 전투 기능, 친구 캐릭터 간의 상호작용 등.


(2) SNS 프로필 관리

SNS를 테마로 학생들이 자신의 프로필을 클래스 형태로 만들어볼 수 있습니다.


class SocialMediaProfile:
    def __init__(self, username, bio):
        self.username = username
        self.bio = bio
        self.posts = []

    def add_post(self, post):
        self.posts.append(post)
        return f"Post added: {post}"

    def show_profile(self):
        return f"@{self.username}\\nBio: {self.bio}\\nPosts: {self.posts}"

# 예시 실행
profile = SocialMediaProfile("cool_kid_123", "Love coding and gaming!")
print(profile.add_post("Hello, world!"))
print(profile.show_profile())

확장 가능성: 댓글, 팔로워 기능 추가.


(3) 애완동물 키우기 시뮬레이션

애완동물을 키우는 클래스는 청소년들에게 친근하게 다가갈 수 있습니다.


class Pet:
    def __init__(self, name, kind):
        self.name = name
        self.kind = kind
        self.happiness = 50
        self.hunger = 50

    def play(self):
        self.happiness += 10
        self.hunger += 5
        return f"{self.name} is happy! Happiness: {self.happiness}, Hunger: {self.hunger}"

    def feed(self):
        self.hunger -= 10
        return f"{self.name} is full! Hunger: {self.hunger}"

# 예시 실행
my_pet = Pet("Buddy", "Dog")
print(my_pet.play())
print(my_pet.feed())

확장 가능성: 애완동물의 종류 추가, 나이 또는 성장 시스템 구현.


2. 학생들이 흥미를 가질만한 활동