MapleStory Finger Point

πŸ’Ž Python/πŸ“šνŒŒμ΄μ¬ for Beginner (2판)

ch 12 μ—°μŠ΅λ¬Έμ œ 풀이 - 파이썬 for Beginner (2판)

HYEJU01 2024. 4. 8. 03:31

1. 클래슀의 μ •μ˜λ‘œ μ˜³μ€ 것은?

2번 객체지ν–₯ ν”„λ‘œκ·Έλž˜λ°μ˜ 핡심 κ°œλ…μ΄λ‹€.

 

1) νŒŒμ΄μ¬μ—μ„œλ§Œ μ œκ³΅λ˜λŠ” κΈ°λŠ₯이 μ•„λ‹Œ μžλ°”,C++ λ“±μ—μ„œλ„ μ œκ³΅λœλ‹€.

2) ν΄λž˜μŠ€μ™€ ν•„λ“œλŠ” λ‹€λ₯Έ μš©μ–΄μ΄λ‹€. > ν΄λž˜μŠ€λŠ” 객체λ₯Ό μ •μ˜ν•˜λŠ” 섀계도, ν•„λ“œλŠ” κ·Έμ•ˆμ˜ 속성듀이닀.

3) 클래슀 μ•ˆμ—λŠ” λ³€μˆ˜λ₯Ό ν¬ν•¨ν•˜λŠ”λ° 이건 λ©”μ„œλ“œκ°€ μ•„λ‹Œ ν•„λ“œλΌκ³  λΆ€λ₯Έλ‹€.

 

2. μžλ™μ°¨ 클래슀 μƒμ„±ν•˜λŠ” μ½”λ“œ

class Car:
    color=""
    speed=-0

    def upSpeed(self,value):
        self.speed += value

    def downpeed(self,value):
        self.speed -= value

 

 

3. μΈμŠ€ν„΄μŠ€ 색상과 속도 좜λ ₯ν•˜λŠ” μ½”λ“œ

class Car:
    color=""
    speed=-0

myCar1 = Car()
myCar1.color = "λΉ¨κ°•"
myCar1.speed = 30

print("μžλ™μ°¨ 색상은 %s, μ†λ„λŠ” %d μž…λ‹ˆλ‹€." %(myCar1.color, myCar1.speed))

 

 

4. 속도λ₯Ό 50으둜 μ΄ˆκΈ°ν™”ν•˜λŠ” 클래슀 μƒμ„±μž μ½”λ“œ

class Car:
    speed=0

def __init__(self):
    self.speed=0

 

5. Car을 상속 λ°›λŠ” RVCar 클래슀 μ •μ˜ν•˜λŠ” μ½”λ“œ

class Car:
    speed=0

    def upSpeed(self,value):
        self.speed = self.speed + value


class RVCar(Car):
    seatNum =0

    def getSeatNum(self):
        return self.seatNum

 

6. λ‹€μŒ μ„€λͺ…에 ν•΄λ‹Ήν•˜λŠ” λ©”μ„œλ“œλŠ”?

 

1) μ†Œλ©ΈμžλΌκ³ λ„ ν•˜λ©° μΈμŠ€ν„΄μŠ€κ°€ μ‚­μ œλ λ•ŒκΉŒμ§€ μžλ™μœΌλ‘œ ν˜ΈμΆœλœλ‹€.----- __del__ ()

2) μΈμŠ€ν„΄μŠ€ μ‚¬μ΄μ˜ λ§μ…ˆ μž‘μ—…μ΄ μΌμ–΄λ‚˜λ©΄ μ‹€ν–‰λ˜λŠ” λ©”μ„œλ“œ ------ __add__() 

3) print() 문으둜 좜λ ₯ν• λ•Œ μ‹€ν–‰λ˜λŠ” λ©”μ„œλ“œ ---- __repr__()

4) μΈμŠ€ν„΄μŠ€ μ‚¬μ΄μ˜ λΉ„κ΅μ—°μ‚°μž <= κ°€ μ‚¬μš©λ λ•Œ ν˜ΈμΆœλ˜λŠ” λ©”μ„œλ“œ ---- __le__()

 

7. νŒŒμ΄μ¬μ—μ„œ 좔상 λ©”μ„œλ“œ 효과λ₯Ό λ‚΄λ €κ³  슈퍼 ν΄λž˜μŠ€μ— μž‘μ„±ν•˜λŠ” ꡬ문은?

pass

 

 

8.λ‹€μŒ μ„€λͺ… 쀑 ν‹€λ¦° 것은?

3) λ©€ν‹°ν”„λ‘œμ„Έμ‹±λ„ start() 둜 μ‹œμž‘λœλ‹€,

join은  μžμ‹ ν”„λ‘œμ„ΈμŠ€κ°€ μœ νœ΄μƒνƒœ(idle)에 λ“€μ–΄κ°€κ³  μ’…λ£Œλ˜μ§€ μ•Šμ•„ μ’€λΉ„ ν”„λ‘œμ„ΈμŠ€κ°€ 됨. 킬 ν•΄μ£ΌλŠ” μ—­ν•