0% found this document useful (0 votes)
2 views

OOOSE Assignment 1

This document is an assignment submitted by Prashant Bhandari for an Object Oriented Software Engineering course at Tribhuvan University. It includes a Python program demonstrating key object-oriented programming concepts such as classes, objects, inheritance, polymorphism, and information hiding. The program defines classes for students, subjects, and sections, and includes methods to display details and manage student information.

Uploaded by

bhandariprs321
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

OOOSE Assignment 1

This document is an assignment submitted by Prashant Bhandari for an Object Oriented Software Engineering course at Tribhuvan University. It includes a Python program demonstrating key object-oriented programming concepts such as classes, objects, inheritance, polymorphism, and information hiding. The program defines classes for students, subjects, and sections, and includes methods to display details and manage student information.

Uploaded by

bhandariprs321
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

TRIBHUVAN UNIVERSITY

INSTITUTE OF SCIENCE AND TECHNOLOGY


KIRTIPUR, NEPAL

ASSIGNMENT 1
OBJECT ORIENTED SOFTWARE ENGINEERING

SUBMITTED BY:
PRASHANT BHANDARI
ROLL NUMBER: 41 (B)

SUBMITTED TO:
PROF. DR. SUBARNA SHAKYA
CENTRAL DEPARTMENT OF COMPUTER SCIENCE &
INFORMATION TECHNOLOGY

March, 2025
Question
Write a program in any object-oriented programming language to include all the
features listed below.

• OBJECTS

• CLASSES

• INSTANCES

• INHERITANCE

• POLYMORPHISM

• Information hiding

Code in Python:
1 # CLASSES AND OBJECTS
2 # Define a class for Student
3 class Student :
4 # Constructor to initialize student details ( Encapsulation -
Information Hiding )
5 def __init__ ( self , name , roll_number , section ) :
6 self . name = name # Public attribute
7 self . roll_number = roll_number # Public attribute
8 self . section = section # Public attribute
9
10 # Method to display student details
11 def display_details ( self ) :
12 print ( f " { self . name } , Roll Number : { self . roll_number } ,
Section : { self . section } " )
13
14 # INHERITANCE
15 # Define a subclass for MSC CSIT Student ( inherits from Student )
16 class MSC_CSIT_Student ( Student ) :
17 def __init__ ( self , name , roll_number , section ) :
18 # Call the parent class constructor to initialize common
attributes
19 super () . __init__ ( name , roll_number , section )
20
21 # POLYMORPHISM
22 # Override the display_details method
23 def display_details ( self ) :
24 # Call the parent class method to display student details
25 super () . display_details ()
26

27 # Define a class for Subject


28 class Subject :
29 def __init__ ( self , subject_name , professor_name ) :
30 self . subject_name = subject_name # Public attribute
31 self . professor_name = professor_name # Public attribute
32

33 # Method to display subject details


34 def display_details ( self ) :
35 print ( f " { self . subject_name } , { self . professor_name } " )
36
37 # Define a class for Section
38 class Section :
39 def __init__ ( self , section_name ) :
40 self . section_name = section_name # Public attribute
41 self . students = [] # List to store students in the section
42
43 # Method to add a student to the section
44 def add_student ( self , student ) :
45 self . students . append ( student )
46
47 # Method to display all students in the section
48 def display_students ( self ) :
49 print ( f " Students in { self . section_name }: " )
50 for student in self . students :
51 student . display_details () # Call the display_details
method of each student
52 print ()
53
54 # Main Program
55 if __name__ == " __main__ " :
56 # Create subjects with professors
57 subjects = [
58 Subject ( " Object Oriented Software Engineering " , " Prof . Dr .
Subarna Shakya " ) ,
59 Subject ( " Advanced Operating Systems " , " Prof . Dr . Binod Kumar
Adhakari " ) ,
60 Subject ( " Algorithms and Complexity " , " Prof . Sarbin Sayami " ) ,
61 Subject ( " Neural Networks " , " Prof . Arjun S . Saud " ) ,
62 Subject ( " Parallel and Distributed Computing " , " Prof . Bikash
Balami " )
63 ]
64
65 # Create sections
66 section_a = Section ( " Section A " )
67 section_b = Section ( " Section B " )
68

69 # Create a list of students for Section A


70 st ud en ts _s ec ti on _a = [
71 Student ( " Manjil " , 1 , " A " ) ,
72 Student ( " Aadarsh " , 2 , " A " ) ,
73 Student ( " Yujan " , 3 , " A " ) ,
74 Student ( " Suraj " , 4 , " A " ) ,
75 Student ( " Samir " , 5 , " A " ) ,
76 Student ( " Rishi " , 6 , " A " )
77 ]
78
79 # Add students to Section A
80 for student in st ud en ts _s ect io n_ a :
81 section_a . add_student ( student )
82
83 # Create a list of students for Section B
84 st ud en ts _s ec ti on _b = [
85 Student ( " Ujwal " , 7 , " B " ) ,
86 Student ( " Prakash " , 8 , " B " ) ,
87 Student ( " Prajwal " , 9 , " B " ) ,
88 Student ( " Bibek " , 10 , " B " ) ,
89 Student ( " Mohan " , 11 , " B " ) ,
90 Student ( " Prashant " , 12 , " B " )
91 ]
92
93 # Add students to Section B
94 for student in st ud en ts _s ect io n_ b :
95 section_b . add_student ( student )
96
97 # Display students in both sections
98 section_a . display_students ()
99 section_b . display_students ()
100
101 # Display list of subjects with professors
102 print ( " List of Subjects and Professors : " )
103 for subject in subjects :
104 subject . display_details ()
Output:

Figure 1: Generated Output

You might also like