วันอาทิตย์ที่ 1 พฤศจิกายน พ.ศ. 2558

Lab 7 - Student (Display)

class Student:
    def __init__(self,name,ID,age,weight,height):
        self.name = name
        self.ID = ID
        self.age = age
        self.weight = weight
        self.height = height

    def display(self):
        print("Name :",self.name)
        print("ID :",self.ID)
        print("Age :",self.age)
        print("Weight :",self.weight)
        print("Height :",self.height,"\n")

def setup():
    std = [Student("ant",58001,39,55,165),
           Student("bird",58010,25,75,170),
           Student("cat",58011,19,44,155),
           Student("dog",58100,30,72,169),
           Student("eagle",58101,22,70,178),
           Student("frog",58110,18,100,175)]

    i = 0
    while(i < len(std)):
        std[i].display()
        i += 1
 
setup()

ไม่มีความคิดเห็น:

แสดงความคิดเห็น