class computer:
def __init__(self, cost, year, cpu_speed, cpu_type):
self.cost = cost
self.year = year
self.cpu_speed = cpu_speed
self.cpu_type = cpu_type
if __name__ == '__main__':
cpu_type = raw_input("The type of CPU inside your computer: ")
cpu_speed = int(raw_input("The speed(MHz) of the CPU?: "))
year = int(raw_input("The year your computer was made?: "))
cost = float(raw_input("How much you paid for the computer?: "))
computer(cost,year,cpu_speed,cpu_type)
print "Hear are what you have entered"
print "Year: ",year,"\n"
print "Cost: ",cost,"\n"
print "CPU type: ",cpu_type,"\n"
print "CPU speed: ",cpu_speed,"MHz"
class employee:
def __init__(self,id1,name):
self.id1 = id1
self.name = name
if __name__ == '__main__':
info = employee(1,"B.Smith")
print "Here is a sample: \n"
print "Employee Name : ",info.name,"\n"
print "Employee ID : ",info.id1
info.name = raw_input("What's your name?: ")
info.id1 = int(raw_input("What's your ID number: "))
print "\nHere are what you entered: \n"
print "Name: ",info.name,"\n"
print "Id: ",info.id1,"\n"
class computer:
def __init__(self, cost, year, cpu_speed, cpu_type):
self.cost = cost
self.year = year
self.cpu_speed = cpu_speed
self.cpu_type = cpu_type
def DataReceiver(s):
cpu_type = raw_input("The type of CPU inside your computer: ")
cpu_speed = int(raw_input("The speed(MHz) of the CPU?: "))
year = int(raw_input("The year your computer was made?: "))
cost = float(raw_input("How much you paid for the computer?: "))
s = computer(cost,year,cpu_speed,cpu_type)
return s
if __name__ == '__main__':
model = DataReceiver(model)
print "Hear are what you have entered"
print "Year: ",model.year,"\n"
print "Cost: ",model.cost,"\n"
print "CPU type: ",model.cpu_type,"\n"
print "CPU speed: ",model.cpu_speed ,"MHz"
# There is no pointer in python
class computer:
def __init__(self, cost, year, cpu_speed, cpu_type):
self.cost = cost
self.year = year
self.cpu_speed = cpu_speed
self.cpu_type = cpu_type
def DataReceiver(s):
cpu_type = raw_input("The type of CPU inside your computer: ")
cpu_speed = int(raw_input("The speed(MHz) of the CPU?: "))
year = int(raw_input("The year your computer was made?: "))
cost = float(raw_input("How much you paid for the computer?: "))
s = computer(cost,year,cpu_speed,cpu_type)
return s
if __name__ == '__main__':
model = DataReceiver(model)
print "Hear are what you have entered"
print "Year: ",model.year,"\n"
print "Cost: ",model.cost,"\n"
print "CPU type: ",model.cpu_type,"\n"
print "CPU speed: ",model.cpu_speed ,"MHz"
class haiku:
def __init__(self,start_year,end_year,author,str1,str2,str3):
self.start_year = start_year
self.end_year = end_year
self.author = author
self.str1 = str1
self.str2 = str2
self.str3 = str3
def DataDisplay(ptr_s):
print ptr_s.str1
print ptr_s.str2
print ptr_s.str3
print " ---",ptr_s.author
print "(",ptr_s.start_year,",",ptr_s.end_year,")"
if __name__ == '__main__':
poem = []
poem.append(haiku(1641,1716,"Sodo","Leading me along","my shadow goes back home","from looking at the moon"))
poem.append(haiku(1729,1781,"Chora","A strom wind blows","out from among the grasses","the full moon grows"))
for i in range(len(poem)):
DataDisplay(poem[i])
class department:
def __init__(self,code,dname,position):
self.code = code
self.dname = dname
self.position = position
class employee:
def __init__(self,code,dname,position,id1,name):
self.DPT = department(code,dname,position)
self.id1 = id1
self.name = name
def InfoDisplay(ptr):
print "Name: ",ptr.name,"\n"
print "ID #: ",ptr.id1,"\n"
print "Dept. name: ",ptr.DPT.dname,"\n"
print "Dept. code: ",ptr.DPT.code,"\n"
print "Your Position : ",ptr.DPT.position,"\n"
def InfoEnter(ptr):
print "Please enter your information:\n"
name = raw_input("Your name: ")
position = raw_input("Your position: ")
name = raw_input("Dept. name: ")
code = raw_input("Dept. code: ")
id1 = raw_input("Your employee ID #: ")
if __name__ == '__main__':
info = employee("1","marketing","manager",1,"B.Smith")
print "\nHere is a sample"
InfoDisplay(info)
InfoEnter(info)
print "\nHere are what you entered"
InfoDisplay(info)