class school:def __init__(self, school_name, school_address):
self.school_name = school_name
self.school_address = school_address
def school_info(self):
def classroom_join(self, classroom_address, classroom_name):
res = classroom(classroom_address, classroom_name)
return res
class classroom:
classroom =
def __init__(self, classroom_address, classroom_name):
self.classroom_name = classroom_name
self.classroom_address = classroom_address
def class_info(self):
print(f'班級名字:,班級所在的校區名字:')
def add_course(self, course_name, course_date, course_price):
res = course(course_name, course_date, course_price)
return res
class course:
def __init__(self, course_name, course_time, course_price):
self.course_name = course_name
self.course_time = course_time
self.course_price = course_price
def course_info(self):
print(f'課程名字:,課程週期:月,課程**:')
class student:
def __init__(self, student_school, student_name, student_age, student_number, student_gender):
self.student_school = student_school
self.student_name = student_name
self.student_age = student_age
self.student_number = student_number
self.student_gender = student_gender
def student_info(self):
print(f'學生學校:,學生姓名:,'
f'學生年齡:,學生學號:.學生性別: ')
def class_choice(self, student, classroom):
print(f'選擇了')
class teacher:
def __init__(self, teacher_name, teacher_age, teacher_salary, teacher_grade):
self.teacher_name = teacher_name
self.teacher_age = teacher_age
self.teacher_salary = teacher_salary
self.teacher_grade = teacher_grade
def teacher_info(self):
print(f'老師的名字: ,老師的年齡:,'
f'老師的薪資:,老師的等級:')
def get_score(self, student_name, score):
print(f'得到了分')
# 主程式
a = school('上海虹橋老男孩', '上海')
a.school_info()
b = a.classroom_join('上海虹橋', 'python14')
b.class_info()
c = b.add_course('python', 6, 21800)
c.course_info()
d = student('上海老男孩', 'zcy', 20, '9', '男')
d.student_info()
d.class_choice('zcy', 'python14')
f = teacher('egon', 20, 30000, '正在相親的老師')
f.teacher_info()
f.get_score('zcy', 80)
物件導向 初識物件導向
面向過程思想 步驟清晰簡單,第一步做什麼,第二步做什麼.面向過程適合處理一些較為簡單的問題 物件導向思想 物以類聚,分類的思維模式,思考問題首先會解決問題需要分哪些類,然後對這些類進行單獨思考,最後才是對某個分類下的細節進行面向過程的思索 物件導向適合處理複雜的問題,適合處理需要多人協作的問題 對於...
物件導向程式設計01 面向過程 物件導向
前面12講我已經寫完了從零開始學j ase 慶祝完結撒花!那麼從今天開始正式步入物件導向程式設計。建議開啟本章之前先回顧 j ase010方法詳解和 j a變數與方法的呼叫 同類操作中與跨類操作中的對比 物件導向程式設計 oop object oriented programming 物件導向程式設...
物件導向過程與物件導向
物件導向過程與物件導向 1 程式的發展經歷了兩個階段 面向過程 物件導向。2 對於物件導向與面向過程可以用乙個例子解釋,如乙個木匠要做乙個盒子,那麼這個盒子的出發點會有兩種方式 物件導向 先想好要做的盒子,之後在去找相應的工具去做。面向過程 不去想要做什麼樣的盒子,隨需取工具。物件導向三大特徵 封裝...