-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathd-oop.py
More file actions
28 lines (22 loc) · 812 Bytes
/
d-oop.py
File metadata and controls
28 lines (22 loc) · 812 Bytes
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
class Student:
"""
This __init__ is a constructor - here is the equivalent Java code:
public Student (String name, String location) {
this.name = name;
}
"""
def __init__(self, first_name, last_name, location):
self.first_name = first_name
self.last_name = last_name
self.location = location
# all methods are always public - no notion of private
def get_full_name(self):
return self.first_name + " " + self.last_name
def _get_location(self):
return self.location
# Student my_student = new Student(name, location...) <- Java equivalent
my_student = Student("Aidan", 'Melvin', 'South Campus Commons')
print(my_student.get_full_name())
# UMDStudent class inherits from Student class
class UMDStudent(Student):
pass