CSC111 studentClass Programs

From dftwiki3
Jump to: navigation, search

--D. Thiebaut 11:51, 7 April 2010 (UTC)



A collection of programs illustrating the use of classes and objects...


Contents


Version 1


""" 
studentClass.py
D. Thiebaut

A program for the Exercises on Class/Objects
Creates a class to keep information about a student.
The class keeps track of the student's name, account number, 
password, and email address.

Object issued from this class have methods to
- print the student information (everything we know about a student)
- create a new student with all the information
- get the name of a student
- get the account number
- get the password
- get the email
- change the email address
"""

text="""
111c-ca, Liz Cloud, xxyzzyK, lcloud@email.smith.edu
111c-cb, Fiona Poory, ahlhla, fpoory@email.smith.edu
111c-ck, Alex Doe, aluoiid, adoe@gmail.com
"""

def parseInput( text ):
    lines = text.split( "\n" )
    List = []
    for line in lines:
        words = line.split( ',' )
        if len( words )==4:
            (account, name, passw, email) = words
        List.append( (account, name, passw, email) )

def main():
    List = parseInput( text )
    
main()



...