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

OpenKM Pricing Overview

lab

Uploaded by

2023200000727
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)
6 views9 pages

OpenKM Pricing Overview

lab

Uploaded by

2023200000727
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

Southeast University

Department of Computer Science & Engineering


Program: [Link]. in CSE
Course Code: CSE 282.2
Course Title: Programming Language II Java Lab
Course Teacher: Mohammed Ashikur Rahman, PhD

Submitted by,
Name: Md. Ruhul Amin
ID: 2023200000812
Section: .2

Lab Task No: 08


Lab Task Name: Object Oriented Programming Concepts
(Abstraction)
OBJECTIVES:
i. To be familiar with abstract methods and abstract classes
ii. To be familiar with interfaces and multiple inheritance
Problem Analysis 01:
The problem is to create a program that represents different types of "Products", such
as electronics, clothing, and books. The common attributes defined in an abstract class
include name and price. Then, we will create three subclasses, "Electronics", "Clothing",
and “Books”, which inherit from the "Store" class. The subclass class will have
type-specific properties. We will also create interfaces for behavior (e.g.,
calculateDiscount()), and multiple inheritance to handle product-specific interfaces in a
main class. Then put them in an ArrayList, and display their information.

Problem Analysis 02:


The problem is to create a program that represents different types of "Vehicle", such as
cars, motorcycles, and trucks. The common attributes defined in an abstract class
include model and year. Then, we will create three subclasses, "Car", "Motorcycles",
and “Trucks”, which inherit from the "Vehicle" class. The subclass class will have
type-specific properties. We will also create interfaces for behavior (e.g., startEngine()),
and multiple inheritance to handle vehicle-specific interfaces in a main class. Then put
them in an ArrayList, and display their information.

Problem Analysis 03:


The problem is to create a program that represents different types of "Bank Account",
such as savings accounts, checking accounts, and credit accounts. The common
attributes defined in an abstract class include account number, balance. Then, we will
create three subclasses, "SavingsAccounts", "CheckingAccounts", and
“CreditAccounts”, which inherit from the "Bank" class. The subclass class will have
type-specific properties. We will also create interfaces for behavior (e.g., deposit(),
withdraw()), and multiple inheritance to handle account-specific interfaces in a main
class. Then put them in an ArrayList, and display their information.

Background Theory:

●​ Abstract classes: In Java, they provide a way to define common attributes and
methods for related Classes.
●​ Interfaces: It is define behavior contracts that can be implemented by classes.
●​ Multiple inheritance: It allows a class to inherit from multiple interfaces,
enabling the implementation of multiple behavior contracts.
●​ Inheritance: Inheritance allows a subclass to inherit properties and methods
from its superclass. It promotes code reuse and provides a hierarchical structure
to classes.
●​ Super Keyword: The "super" keyword is used to refer to the superclass's
members (properties or methods, or constructors) from a subclass. It is
particularly useful when the superclass and subclass have members with the
same name, and we need to differentiate between them.
●​ ArrayList and LinkedList are two commonly used data structures in Java.
ArrayList is implemented as a dynamic array, while LinkedList is implemented as
a doubly-linked list. ArrayList provides fast random access, while LinkedList
provides efficient insertion and deletion operations.
●​ Constructors: In Java, a constructor is a special method that is used to initialize
objects of a class. It has the same name as the class and does not have a return
type, not even void. Constructors are called implicitly when an object is created
using the new keyword. They are used to set initial values to the instance
variables of an object.
●​ Key Points about the ‘this’ Keyword:
○​ ‘this’ can be used to refer to instance variables within a class.
○​ ‘this’ can be used to invoke a constructor from another constructor within
the same class.
○​ ‘this’ can be used to return the current object from a method.
●​ Method Overriding: Method overriding is the ability of a subclass to provide a
different implementation of a method that is already defined in its superclass. It
allows us to define specialized behavior in the subclass.

Algorithm Design for Different Types of Products:


1.​ Define the "Store" abstract class:
a.​ Declare properties: name and price.
b.​ Create a parameterized constructor to initialize the properties.
c.​ Provide getters and setters for each property.
d.​ Defined an abstract calculateDiscount().
e.​ Include an object method display() in the Store class to display the store's
different types of product details.
2.​ Define the subclass "Electronics" class:
a.​ Inherit from the "Store" class using the "extends" keyword.
b.​ Declare a private property: specification.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the seats property.
e.​ Implement the abstract method for calculating the available discount from
the main price of a product.
f.​ Override the display() method to display the information of the Electronics
(also discounted price) object.
3.​ Define the subclass "Clothing" class:
a.​ Inherit from the "Store" class using the "extends" keyword.
b.​ Declare a private property: clothType.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the cloth type property.
e.​ Implement the abstract method for calculating the available discount from
the main price of a product.
f.​ Override the display() method to display the information of the Clothing
(also discounted price) object.
4.​ Define the subclass "Books" class:
a.​ Inherit from the "Store" class using the "extends" keyword.
b.​ Declare a private property: author.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the author property.
e.​ Implement the abstract method for calculating the available discount from
the main price of a product.
f.​ Override the display() method to display the information of the Clothing
(also discounted price) object.
5.​ Define the "Main" class in the interface:
a.​ Create an ArrayList to store Store objects.
b.​ Initialize Electronics, Clothing, and Books objects using the parameterized
constructors.
c.​ Add the objects to the ArrayList.
d.​ Iterate over the ArrayList and display the information of each object using
the display() method.

Code:
[Link]
Output:

Algorithm Design for Vehicle class:


1.​ Define the "Vehicle" abstract class:
a.​ Declare private properties: model and year.
b.​ Create a parameterized constructor to initialize the properties.
c.​ Provide getters and setters for each property.
d.​ Defined an abstract method startEngine ().
e.​ Include an object method display() in the Vehicle class to display the
Vehicle’s details.
2.​ Define the subclass "Car" class:
a.​ Inherit from the "Vehicle" class using the "extends" keyword.
b.​ Declare a private property: seats.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the seats property.
e.​ Implement the abstract method by setting the engine size and how it
started.
f.​ Override the display() method to display the information of the Car object.
3.​ Define the subclass "Motorcycles" class:
a.​ Inherit from the "Vehicle" class using the "extends" keyword.
b.​ Declare a private property: vehicle type.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the vehicle type property.
e.​ Implement the abstract method by setting the engine size and how it
started.
f.​ Override the display() method to display the information of the Motorcycles
object.
4.​ Define the subclass "Trucks" class:
a.​ Inherit from the "Vehicle" class using the "extends" keyword.
b.​ Declare a private property: capacity.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the capacity property.
e.​ Implement the abstract method by setting the engine size and how it
started.
f.​ Override the display() method to display the information of the Trucks
object.
5.​ Define the "Main" class in the interface:
a.​ Create an ArrayList to store Vehicle objects.
b.​ Initialize Car, Motorcycles, and Trucks objects using the parameterized
constructors.
c.​ Add the objects to the ArrayList.
d.​ Iterate over the ArrayList and display the information of each object using
the display() method.

Code:
[Link]
Output:

Algorithm Design for Bank Account:


1.​ Define the "Bank" abstract class:
a.​ Declare private properties: account number, balance.
b.​ Create a parameterized constructor to initialize the properties.
c.​ Provide getters and setters for each property.
d.​ Defined an abstract method deposit () and withdraw().
e.​ Include an object method display() in the Bank class to display the
Accounts details.
2.​ Define the subclass "Saving Account" class:
a.​ Inherit from the "Bank" class using the "extends" keyword.
b.​ Declare a private property: interestRate.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the interest rate property.
e.​ Implement the abstract method by setting the deposit and withdrawal
operations, calculating them, and then showing the total balance.
f.​ Override the display() method to display the information of the Saving
Account (also the total left balance) object.
3.​ Define the subclass "Checking Account" class:
a.​ Inherit from the "Bank" class using the "extends" keyword.
b.​ Declare a private property: limit.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the overdraft limit property.
e.​ Implement the abstract method by setting the deposit and withdrawal
operations with an overdraft limit, calculating them then showing the total
balance.
f.​ Override the display() method to display the information of the Checking
Account (also the total left balance with overdraft limit) object.
4.​ Define the subclass "Credit Account" class:
a.​ Inherit from the "Bank" class using the "extends" keyword.
b.​ Declare a private property: creditLimit.
c.​ Create a parameterized constructor that includes the additional property.
d.​ Provide a getter and setter for the credit limit property.
e.​ Implement the abstract method by setting the deposit and withdrawal
operations with a credit limit, calculating them, and then showing the total
balance.
f.​ Override the display() method to display the information of the Saving
Account (also the total left balance with credit limit) object.
5.​ Define the "Main" class in the interface:
a.​ Create an ArrayList to store Bank objects.
b.​ Initialize Savings Accounts, Checking Accounts, and Credit Accounts
objects using the parameterized constructors.
c.​ Add the objects to the ArrayList.
d.​ Iterate over the ArrayList and display the information of each object using
the display() method.

Code:
[Link]
Output:

You might also like