



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Object-oriented programming (OOP) is a programming paradigm based on the concept of 'objects', which can contain data and code. The data is in the form of fields (often known as attributes or properties), and the code is in the form of procedures (often known as methods).
2.1. Class and Object
Classes and objects are the two main aspects of object-oriented programming. Basically, a class is a template for objects, and an object is an instance of a class. When the individual objects are created, they inherit all the variables and methods from the class.
For example: In the program, an "car" class is created with the variable "orange". The "car" class is then used to create an object "Bumblebee", and the color of the object can be printed.
2.2. Encapsulation
In software systems, encapsulation refers to the bundling of data with the mechanisms or methods that operate on the data. It may also refer to the limiting of direct access to some of that data, such as an object's components. In short, Encapsulation exists to make sure 'sensitive' data is hidden from users.
For example: In the "DemoEncap" class, the variables are declared as private. To access these private variables, public accessors (get and set methods) are used to retrieve and set the values of the private fields.
2.3. Abstraction
Data abstraction is the process of hiding certain details and showing only essential information to the user.
For example: An abstract class named "animalSound()" with a "sleep()" method is created. The "Pig" class inherits the "Animal" class and overrides the original "Animal" method using the "override" keyword. In the program, a new object is created, and the abstract method is called.
2.4. Polymorphism
Polymorphism is the ability of any data to be processed in more than one form, and it occurs when we have many classes that are related to each other by inheritance.
For example: A class called "Animal" is created with a method called "animalSound()". Derived classes of "Animals" could be "Pigs", "Cats", "Dogs", "Birds" - These also have an implementation of an animal sound (the pig oinks, and the cat meows, etc.). In C#, the "Inherit" symbol ":" is used. Finally, "Pig" and "Dog" objects are created, and the "animalSound()" method is called on both, which have different outputs.
2.5. Inheritance
In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining a similar implementation. Also defined as deriving new classes (sub classes) from existing ones such as super class or base class and then forming them into a hierarchy of classes.
For example: In C#, the child class can inherit the parent class by using the ":" symbol. In the program, the "Car" class (child) inherits the fields and methods from the "Vehicle" class (parent).
3.1. Association
Association is a relation between two separate classes which is established through their Objects. Association can be one-to-one, one-to-many, many-to- one, many-to-many.
In the example, two classes are created: "Organization" and "Employee". An "Organization" can have many "Employees", which is a "one to many" relationship in the association line.
3.2. Aggregation
Aggregation is a type of relationship between two classes in object-oriented programming where one class contains a reference to another class. It is a 'has-a' relationship, which means that a class A has a reference to an instance of class B, but the existence of class A does not depend on the existence of class B.
The Store class represents the store itself, with attributes such as storeId, name, and address. The relationship between Store and StoreOwner is one- to-one, as noted above.
The Customer class has attributes such as customerId, name, email, and cart, representing the products (in this case, books) in the customer's cart. The relationship between the customer and the book product is many-to- many, as a customer can have multiple products in their cart, and a single book can be in multiple customers' carts.
Sequence Diagrams
The provided sequence diagrams illustrate the following scenarios:
This sequence diagram shows the process of a customer adding an item to their cart. The system checks the inventory to ensure the item is available, and then reports the availability to the customer, allowing them to proceed with the purchase.
This sequence diagram shows the process of a customer removing an item from their cart. The system checks the inventory to ensure the item is available, and then reports the availability to the customer, allowing them to proceed with the purchase.
This sequence diagram shows the process of the store owner logging in to the system and requesting a sales report. The sales system generates the sales report, and the store system displays it for the owner.
This sequence diagram shows the process of the customer making a purchase. The system processes the payment using a payment gateway, updates the inventory, and notifies the customer of a successful transaction.
References
Object Oriented Programming Using C# .NET Available at: https:// www.c-sharpcorner.com/UploadFile/84c85b/object-oriented- programming-using-C-Sharp-net/ [Accessed April 6, 2023] Types Of Relationships in Object Oriented Programming (OOPS) Available at: https://www.linkedin.com/pulse/types-relationships-object- oriented-programming-oop-sarah-el- dawody#:~:text=Object%20oriented%20programming%20generally%20support, %2C%20association%2C%20composition%20and%20aggregation. [Accessed April 6, 2023] Dependency, Generalization, Association, Aggregation, Composition in Object Oriented Programming. [Accessed April 6, 2023] Class diagram of OOP. [Accessed 16 April, 2023] Class diagram of OOP Student Available at: https:// www.geeksforgeeks.org/class-diagram-for-school-management-system/ [Accessed 16 April, 2023] Saini, A. (2023) C#: Encapsulation, GeeksforGeeks. GeeksforGeeks. Available at: https://www.geeksforgeeks.org/c-sharp-encapsulation/ (Accessed: April 16, 2023) C# Polymorphism (2023) C# polymorphism. C# Inheritance (2023) C# inheritance. C# properties (2023) C# properties (get and set).