Skip to content

Instantly share code, notes, and snippets.

@gothedistance
Created September 9, 2016 12:34
Show Gist options
  • Save gothedistance/db435f850c3d78c23475956e5975d25d to your computer and use it in GitHub Desktop.
Save gothedistance/db435f850c3d78c23475956e5975d25d to your computer and use it in GitHub Desktop.
スクーさんの授業で作ったアドレス帳のソースコードです
class AddressBook:
person_list = []
def add(self, person):
self.person_list.append(person)
def list_all(self):
for p in self.person_list:
print(p.lastname + " " + p.firstname)
def search(self,k):
for p in self.person_list:
if k in p.firstname:
print(p.firstname)
class Person:
firstname = ''
lastname = ''
import datetime
birthday = datetime.date(1979,11,12)
abook = AddressBook()
yumoto = Person()
yumoto.firstname = 'みちたか'
yumoto.lastname = 'ゆもと'
abook.add(yumoto)
tokuda = Person()
tokuda.firstname = 'あおい'
tokuda.lastname = 'とくだ'
abook.add(tokuda)
abook.list_all()
abook.search('あおい')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment