Module student :: Class Student
[hide private]
[frames] | no frames]

Class Student

source code

object --+
         |
        Student

The class Student represents students in an excursion signup system. Each student is characterized by its name and "year of study" (i.e., 1 for freshmen, 2 for sophomores, etc.). A student object is immutable after creation (we don't need to change, say, the year of study in the context of this program).

Instance Methods [hide private]
 
__init__(self, name, year_of_study)
Creates a new student with the given name and year of study.
source code
 
get_name(self)
Returns the student's name.
source code
 
get_year_of_study(self)
Returns the student's year of study.
source code
 
is_older_than(self, another_student)
Determines if this student is "older", in terms of years studied, than another, given student.
source code
 
get_description(self)
Returns a string description of the student.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, year_of_study)
(Constructor)

source code 

Creates a new student with the given name and year of study.

Parameters:
  • name - the student's name
  • year_of_study - the student's year of study
Overrides: object.__init__

get_name(self)

source code 

Returns the student's name.

Returns:
student name

get_year_of_study(self)

source code 

Returns the student's year of study.

Returns:
year of study

is_older_than(self, another_student)

source code 

Determines if this student is "older", in terms of years studied, than another, given student.

Parameters:
  • another_student - another student to compare to
Returns:
a boolean value indicating if this student is "older" than the given one

get_description(self)

source code 

Returns a string description of the student. The description is of the form "StudentName (YearOfStudy)". E.g. "Bob (3)".

Returns:
string description of student