0% found this document useful (0 votes)
10 views3 pages

Assignment 2 - OOP

The document contains an assignment on Object-Oriented Programming (OOP) with two tasks. Task 1 defines a 'Student' class with methods to display student information, while Task 2 introduces an 'Employee' class and a derived 'Manager' class that displays employee and manager details, respectively. The assignment includes examples of creating instances and invoking methods for both tasks.

Uploaded by

shakebahmed09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Assignment 2 - OOP

The document contains an assignment on Object-Oriented Programming (OOP) with two tasks. Task 1 defines a 'Student' class with methods to display student information, while Task 2 introduces an 'Employee' class and a derived 'Manager' class that displays employee and manager details, respectively. The assignment includes examples of creating instances and invoking methods for both tasks.

Uploaded by

shakebahmed09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

# Name: Shatel Ahmed

# ID: 22-48480-3

Submission Date: 24 May 2025

Assignment 2: Object-Oriented Programming (OOP)

Course: Object-Oriented Programming [MIS]

Task 1: Class and Object

class Student:

def __init__(self, name, roll_number, course):

self.name = name

self.roll_number = roll_number

self.course = course

def display_info(self):

"""Displays student information"""

print("Student Name:", self.name)

print("Roll Number:", self.roll_number)

print("Course:", self.course)

print()

student1 = Student("Alice", "MIS123", "Object-Oriented Programming")

student2 = Student("Bob", "MIS124", "Data Structures")


student1.display_info()

student2.display_info()

Task 2: Inheritance

class Employee:

def __init__(self, name, emp_id, salary):

self.name = name

self.emp_id = emp_id

self.salary = salary

def show_details(self):

"""Displays employee details"""

print("Employee Name:", self.name)

print("Employee ID:", self.emp_id)

print("Salary:", self.salary)

class Manager(Employee):

def __init__(self, name, emp_id, salary, department):

super().__init__(name, emp_id, salary)

self.department = department
def show_details(self):

"""Displays manager details including department"""

super().show_details()

print("Department:", self.department)

manager1 = Manager("Charlie", "E102", 75000, "Marketing")

print()

manager1.show_details()

You might also like