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

Class Student

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.
string
get_name(self)
Returns the student's name.
int
get_year_of_study(self)
Returns the student's year of study.
boolean
is_older_than(self, another_student)
Determines if this student is "older", in terms of years studied, than another, given student.
string
get_description(self)
Returns a string description of the student.

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)

 

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

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

get_name(self)

 

Returns the student's name.

Returns: string
student name

get_year_of_study(self)

 

Returns the student's year of study.

Returns: int
year of study

is_older_than(self, another_student)

 

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

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

get_description(self)

 

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

Returns: string
string description of student