12.6 Practice


Student Class

Create a class called Student with instance attributes: Name and Age. The user can input the name and age. Add 2 methods to the class: a raiseHand method, which prints out the student's name followed by "is now raising their hand" and a growOlder method that makes the student older by 1 year.

Teacher Class

Create a class called Teacher. Add 3 variables to this class: Name, Age, and a list of Student classes from the previous problem (the list can just be called students). The user can input these 3 variables. Add 2 methods to the class: a displayClass method that prints out the names of all the students, and a graduate method that increments the age of all of his/her students by 1 and prints out all the ages

Previous Section

Next Section


Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.