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

[LAB7] BANNER LETTER #INCOMPLETE

class words:
   def __init__(self,first,second,third,fourth,fifth):
      self.first = first
      self.second = second
      self.third = third
      self.fourth = fourth
      self.fifth = fifth
 
   def display_L_first(self):
      print(self.first,end = "")
   def display_L_second(self):
      print(self.second,end = "")
   def display_L_third(self):
      print(self.third,end = "")
   def display_L_fourth(self):
      print(self.fourth,end = "")
   def display_L_fifth(self):
      print(self.fifth,end = "")
   
   def get_word_L_first(self):
      return self.first
   def get_word_L_second(self):
      return self.second
   def get_word_L_third(self):
      return self.third
   def get_word_L_fourth(self):
      return self.fourth
   def get_word_L_fifth(self):
      return self.fifth
 
   def star_first(self):
      hashtag_star(self.first)
   def star_second(self):
      hashtag_star(self.second)
   def star_third(self):
      hashtag_star(self.third)
   def star_fourth(self):
      hashtag_star(self.fourth)
   def star_fifth(self):
      hashtag_star(self.fifth)
   
   
def setup():
   B = words("#####","#   #","#####","#   #","#####")
   U = words("#   #","#   #","#   #","#   #"," ### ")
   N = words("#   #","##  #","# # #","#  ##","#   #")
   G = words(" ####","#    ","# ###","#   #","#####")
   letter = [B,U,N,G]
   word = input("")
   draw_word(letter,word)

def draw_word(letter,word):
   i_print = 0
   while(i_print < 5):
      i = 0
      while(i < len(word)):
         if(word[i] == "B"):
            fun_print(letter,i_print,0)
         elif(word[i] == "L"):
            fun_print(letter,i_print,1)
         elif(word[i] == "U"):
            fun_print(letter,i_print,2)
         elif(word[i] == "E"):
            fun_print(letter,i_print,3)
         i = i + 1
         print()
         i_print = i_print + 1

def hashtag_star(temp):
   i = 0
   while(i < len(temp)):
         if(temp[i] == "#"):
            print("*",end = "")
         else:
            print(" ",end = "")
         i = i + 1
       
def fun_print(letter,i_print,word_index):
   if(i_print == 0):
      letter[word_index].star_first()
   elif(i_print == 1):
      letter[word_index].star_second()
   elif(i_print == 2):
      letter[word_index].star_third()
   elif(i_print == 3):
      letter[word_index].star_fourth()
   elif(i_print == 4):
      letter[word_index].star_fifth()
 
setup()

[LAB7] AGE #INSERT-SORT

class DataStudents:
   def __init__(self,name,sID,ages,heights,weights):
      self.name = name
      self.sID = sID
      self.age = ages
      self.height = heights
      self.weight = weights
     
   def get_age(self):
      return self.age
   def get_name(self):
      return self.name
     
     
def setup():
   nop = DataStudents("Nop",20046,28,173,52)
   pee = DataStudents("Pee",20054,35,176,78)
   fern = DataStudents("Fern",20097,26,174,58)
   Recond = [nop,pee,fern]
   #average_age(Recond)
   #less_than_30(Recond)
   sort(Recond)
 
def average_age(Recond):
   i = 0
   total = 0
   a = 0
   while(i < len(Recond)):
         total = total + Recond[i].get_age()
         i = i + 1
   a = total / len(Recond)
   print("%.2f"%a)
 
def less_than_30(Recond):
   i = 0
   while(i < len(Recond)):
      if(Recond[i].get_age() < 30):
         print(Recond[i].get_name())
         print(Recond[i].get_age())
      i = i + 1
     
def sort(Recond):
   i = 0
   j = 1
   charge = 0
   min_age = 0
   while(i < len(Recond)):
      min_age = Recond[i].get_age()
      while(j < len(Recond)):
         if(min_age > Recond[j].get_age()):
            charge = min_age
            min_age = Recond[j].get_age()
            Recond[j].get_age() = charge
         j = j + 1
      print(Recond[i].get_name())
      print(Recond[i].get_age())
      print()
      i = i + 1
     
setup()

[LAB7] BMI

class DataStudents:
   def __init__(self,name,sID,ages,heights,weights):
      self.name = name
      self.sID = sID
      self.age = ages
      self.height = heights
      self.weight = weights
     
   def get_name(self):
      return self.name
   def get_height(self):
      return self.height
   def get_weight(self):
      return self.weight
     
     
     
def setup():
   nop = DataStudents("Nop",20046,28,173,52)
   pee = DataStudents("Pee",20054,35,176,78)
   fern = DataStudents("Fern",20097,26,174,58)
   Recond = [nop,pee,fern]
   find_BMI_more_than_25(Recond)
 
def find_BMI_more_than_25(Recond):
   i = 0
   BMI = 0
   while(i < len(Recond)):
      BMI = Recond[i].get_weight()/((Recond[i].get_height()/100) * (Recond[i].get_height()/100))
      if(BMI > 25):
         print(Recond[i].get_name())
         print("%.2f"%BMI)
      i = i + 1
 
setup()

[LAB7] Data Student

class DataStudents:
   def __init__(self,name,sID,ages,heights,weights):
      self.name = name
      self.sID = sID
      self.age = ages
      self.height = heights
      self.weight = weights
     
   def display(self):
      print(self.name)
      print(self.sID)
      print(self.age)
      print(self.height)
      print(self.weight)
     
def setup():
   nop = DataStudents("Nop",20046,28,173,52)
   pee = DataStudents("Pee",20054,35,176,67)
   fern = DataStudents("Fern",20097,26,174,58)
 
   nop.display()
   print()
   pee.display()
   print()
   fern.display()
   print()
 
setup()