-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathname_base_class.py
67 lines (53 loc) · 1.67 KB
/
name_base_class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 21 03:37:01 2018
@author: Arjun Nath
"""
import sys
import os
class Name(object):
'''
A class to hold names with some basic class methods
'''
STR_SPACE = " "
STR_DOT = "."
# def __init__(self, firstname ="", middlename = None, lastname = "" ):
def __init__(self, *args, **kwargs):
'''
class constructor - Initialize name variables
Constructor can take 2 or 3 string names
'''
if len(args) == 2 :
self.firstname = args[0]
self.middlename = None
self.lastname = args[1]
#print("Base class init. Names are :" + self.firstname + " " + self.lastname )
if len(args) == 3 :
self.firstname = args[0]
self.middlename = args[1]
self.lastname = args[2]
#print("Base class init. Names are :" + self.firstname + " " + self.middlename + " " + self.lastname )
def get_firstname(self):
return self.firstname
def get_middlename(self):
return self.middlename
def get_lastname(self):
return self.lastname
def set_firstname(self, fname):
self.firstname = fname
def set_middlename(self, mname):
self.middlename = mname
def set_lastname(self, lname):
self.lastname = lname
@classmethod
def isName(self):
'''
Every name should have at least one first and one last name
'''
try :
if self.firstname == "" or self.lastname == "" :
return False
else :
return True
except :
print("Exception in isName()")