公開屬性與私有屬性
太好了!你的同事決定在他們正在開發的銀行 App 中使用物件導向程式設計。現在他們需要你幫忙實作其中一個類別,這個類別會同時用到公開與私有屬性。
本練習屬於課程
Programming Paradigm 概念
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Define the Car class
class Car():
def __init__(self, price):
# price is a public attribute
self.____ = price