Created
September 9, 2016 12:34
-
-
Save gothedistance/db435f850c3d78c23475956e5975d25d to your computer and use it in GitHub Desktop.
スクーさんの授業で作ったアドレス帳のソースコードです
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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