0% found this document useful (0 votes)
20 views9 pages

Areeba

OOP LAB MANUAL 2024

Uploaded by

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

Areeba

OOP LAB MANUAL 2024

Uploaded by

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

Superior Group of colleGeS

Khurrianwala

Bachelor of Science in Computer


Science

Assignment

Student name: Areeba


Father name: Muhammad Boota
Submitted to: Sir Ahmad
Course code: CSI-312
Course code: Object Oriented Programming
language
Semester: BSCS-II
object oriented proGramminG

Topic 1:Object-Oriented Program Design Process

Phase 1: Analysis
• Identify Problem Domain: Define the problem and its boundaries.
• Gather Requirements: Collect functional and non-functional requirements.
• Develop Use Cases: Describe system interactions.
• Create Conceptual Model: Identify key concepts and relationships.

Phase 2: Design
• Develop Class Diagrams: Visualize classes and relationships.
• Identify Classes and Objects: Define classes and objects.
• Define Attributes and Methods: Specify data and behavior.
• Establish Relationships: Define inheritance, composition, and associations.

Phase 3: Implementation
• Choose Programming Language: Select an OO language.
• Write Class Definitions: Implement classes and objects.
• Implement Methods: Code behavior.
• Test and Debug: Verify correctness.

Phase 4: Testing and Maintenance


• Develop Test Cases: Create test scenarios.
• Conduct Unit Testing: Test individual classes.
• Conduct Integration Testing: Test interactions.
• Refactor and Maintain: Improve and update code.

Example OO Program Design Process


Design an object-oriented program for a simple banking system. The system should
allow users to:

1. Create accounts
2. Deposit funds
3. Withdraw funds
4. Check account balance

Requirements:
• Use object-oriented design principles (encapsulation, inheritance,
polymorphism)
• Identify and create necessary classes and objects
• Define attributes and methods for each class
• Establish relationships between classes
• Provide a simple user interface (console-based)

Deliverables:
• Class diagram (UML)
• Object diagram (UML)
• Source code (Java, C++, or Python)
• Written report (design decisions, explanations)

Design Guidelines:
• Separate concerns (use separate classes for account, customer, transaction)
• Use inheritance for shared attributes and methods
• Encapsulate data and behavior
• Use polymorphism for transaction types (deposit, withdrawal)
• Consider scalability and maintainability

Classes and Objects:


1. Customer
- Attributes: name, address, account number
- Methods: getAccountNumber(), getAccountBalance()
2. Account
- Attributes: account number, balance, customer
- Methods: deposit (), withdraw (), get Balance ()
3. Transaction
- Attributes: transaction type, amount, date
- Methods: process Transaction ()
4. Bank
- Attributes: list of accounts
- Methods: create Account (), get Account ()

Additional Requirements:
• Validate user input
• Handle errors and exceptions
• Provide basic security measures (password protection)

Submission:
Please submit your design documents (class diagram, object diagram), source code,
and written report as separate files.

Topic2: Problem Solving Paradigm


A problem-solving paradigm is a framework for understanding and resolving
complex problems.

OO Problem Solving Steps


• Define: Identify the problem and its constraints.
• Analyze: Break down the problem into smaller sub-problems.
• Design: Create a solution framework using OO concepts (classes,
objects, inheritance, polymorphism).
• Implement: Write code to implement the solution.
• Test: Verify the solution's correctness.
• Refine: Improve the solution based on feedback.

OO Problem Solving Strategies


• Encapsulation: Hide internal implementation details.
• Abstraction: Focus on essential features and hide implementation
details.
• Inheritance: Create new classes from existing ones.
• Polymorphism: Use method overriding or method overloading.
• Composition: Use objects to represent complex structures.

OO Problem Solving Techniques


• Class-Responsibility-Collaboration (CRC) Cards: Identify classes,
responsibilities, and collaborations.
• Unified Modeling Language (UML): Use diagrams to visualize OO
designs.
• Use Cases: Identify system interactions.
• Sequence Diagrams: Visualize object interactions.
• State Machine Diagrams: Model object states.

Problem:
Design a system to manage students and courses.

Step 1: Identify Classes and Objects


• Student
• Course
• Instructor

Step 2: Define Attributes and Methods


Student:
- Attributes: name, ID, grades
- Methods: enrollCourse(), dropCourse()
Course:
- Attributes: name, ID, instructor
- Methods: addStudent(), removeStudent()
Instructor:
- Attributes: name, ID
- Methods: teachCourse()
Step 3: Establish Relationships
• A student can enroll in many courses.
• A course can have many students.
• An instructor teaches many courses.

Topic 3: Object-Oriented Concept and Principles


Key OOP Concepts:
1. Encapsulation:
Encapsulation is the concept of bundling data and methods that operate on that data
within a single unit, making it harder for other parts of the program to access or
modify the data directly.
- Example: Book, Member, and Library classes encapsulate their respective data
members (attributes) and member functions (methods).

2. Abstraction:
Abstraction is the practice of showing only the necessary information to the outside
world while hiding the background details or implementation.
- Example: The classes abstract the complexity of the library management system,
exposing only necessary information.

3. Inheritance:
Inheritance allows one class to inherit the properties and behavior of another class.
- Example: Not used in this example, but could be applied if we had different types
of books (e.g., fiction, non-fiction).

4. Polymorphism:
Polymorphism is the ability of an object to take on multiple forms.
- Example: Demonstrated through function overloading (e.g., search Book).

5. Composition:
Composition is a design pattern that allows objects to contain other objects.

SOLID Principles
1. Single Responsibility Principle (SRP)
A class should have only one reason to change.
- Benefits: Easier maintenance, reduced coupling.
- Example: Separate logging and calculation responsibilities.

2. Open-Closed Principle (OCP)


A class should be open for extension but closed for modification.
- Benefits: Improved flexibility, reduced fragility.
- Example: Use inheritance or interfaces for extension.

3. Liskov Substitution Principle (LSP)


Derived classes should be substitutable for their base classes.
- Benefits: Improved polymorphism, reduced errors.
- Example: Ensure derived classes honor base class contracts.

4. Interface Segregation Principle (ISP)


5. Clients should not be forced to depend on interfaces they don't use.
- Benefits: Reduced coupling, improved flexibility.
- Example: Split large interfaces into smaller, client-specific ones.

6. Dependency Inversion Principle (DIP)


High-level modules should not depend on low-level modules.
- Benefits: Reduced coupling, improved maintainability.
- Example: Use abstraction layers or interfaces.

C++ Concepts:
1. Classes and Objects: Define custom data types.
- Example: Book, Member, Library classes.
2. Constructors: Initialize objects.
- Example: Book constructor initializes title, author, and ISBN.
3. Member Functions: Perform operations on objects.
- Example: Book class has borrowed and return Book methods.
4. Vectors: Store collections of objects.
- Example: Library class uses vectors to store books and members.

You might also like