Make your choice.

    Everyday,actually,we have two chioces- to choose a good mood or a bad one.

 

    ......

 

 

    So which one will you choose today?

 

    Please remember it's totally up to youself.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
代码中存在以下错误: 1. 在调用方法时,应该使用对象调用方法,而不是类名调用方法。 2. 在子类 `Student` 中,没有定义 `get_information` 方法。 3. 在调用 `modify_course` 方法时,应该传递课程编号 `course_id2`,而不是学生对象 `student`。 以下是修正后的代码: ``` class Person: def __init__(self, last_name, first_name, gender, birthday): self.last_name = last_name self.first_name = first_name self.gender = gender self.birthday = birthday class Student(Person): def __init__(self, last_name, first_name, gender, birthday, student_id, major): super().__init__(last_name, first_name, gender, birthday) self.student_id = student_id self.major = major self.selected_courses = {} def select_course(self, course): self.selected_courses[course.course_id] = course def modify_course(self, course_id): del self.selected_courses[course_id] def get_information(self, course_id): if course_id in self.selected_courses: print(f"Course ID:{course_id}, Course Name:{self.selected_courses[course_id].name}, Course Credit:{self.selected_courses[course_id].credit}") else: print("The selected course does not exist.") class Course: def __init__(self, course_id, name, credit): self.course_id = course_id self.name = name self.credit = credit def f2(): print('''If you want to get the information of selected courses, choose number 1. If you want to modify selected courses, choose number 2.''') choice1 = input('Please make your choice:') student_id = input('Please input your student_id:') student = Student('', '', '', '', student_id, '') if choice1 == '1': course_id1 = input('Please input the course_id you want to query:') student.get_information(course_id1) if choice1 == '2': choice11 = input('Choose your following operation(1.add;2.delete):') course_id2 = input('Please input the course_id you want to query:') if choice11 == '1': course_name = input('Please input the course name:') course_credit = input('Please input the course credit:') course = Course(course_id2, course_name, course_credit) student.select_course(course) if choice11 == '2': student.modify_course(course_id2) ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值