// creating four main classes
Clients – users who required a solution .
Consultant – solution provider
Services – IT consulting services
Projects – Managed IT projects for clients.
oops concept :
1. Encapsulation
situation or where we can use in our application :
Protecting sensitive client and employee data within Oracle HCM
class Client {
constructor(name, email, service) {
[Link] = name;
[Link] = email;
[Link] = service;
}
method to get information
getClientInfo() {
return ` Client: ${[Link]}, service: ${[Link]}`;
}
method update or set data
updatename (newname) {
[Link] = newname;
}
updateProject(newProject) {
[Link] = newservice;
}
}
// Creating an instance
const client1 = new Client("name ", "email", "type of service ");
2. Inheritence
Use Case: Creating a common Consultant class and extending it for different
specializations.
// can be used to store the consultant exprtise , exprience etc
main service for all
Parent Class → Consultant
every individual services as child classes :
a. OracleHCMConsultant
b. OpenTextConsultant
// Parent class: Consultant
class Consultant {
constructor(name, expertise, experience) {
[Link] = name;
[Link] = expertise;
[Link] = experience;
}
getDetails() {
return `${[Link]} is an expert in ${[Link]} with $
{[Link]} years of experience.`;
}
}
class OracleHCMConsultant extends Consultant {
constructor(name, experience) {
super(name, "Oracle HCM", experience);
[Link] = certification;
}
getDetails() {
return `${[Link]()} Certified as ${[Link]}.`;
}
}
const oracleConsultant = new OracleHCMConsultant("any name ", "type of service ",
experience required for thee client );
// Abstraction
// Abstract class: Consultant (Cannot be instantiated directly)
class Consultant {
constructor(name, expertise, experience) {
if ([Link] === Consultant) {
throw new Error("Cannot instantiate an abstract class!");
}
[Link] = name;
[Link] = expertise;
[Link] = experience;
}
// Abstract method (must be implemented by child classes)
getDetails() {
throw new Error("Method 'getDetails()' must be implemented.");
}
}
// Child class: Oracle HCM Consultant
class OracleHCMConsultant extends Consultant {
constructor(name, certification, experience) {
super(name, "Oracle HCM", experience);
[Link] = certification;
}
// Implementing the abstract method
getDetails() {
return `${[Link]} is an expert in ${[Link]} with $
{[Link]} years of experience. Certified as ${[Link]}.`;
}
}
// Creating instances
const oracleConsultant = new OracleHCMConsultant("Alice", "Oracle Certified HCM
Specialist", 7);
const openTextConsultant = new OpenTextConsultant("Bob", 15, 10);
const techLead = new TechnicalLead("Charlie", 25, 15);
polymorphism
Use Case: Handling different types of support requests dynamically.
Implementation: Using method overriding to customize responses. the function with
same name but different types or number of arguement
// Parent class: Consultant
class Consultant {
constructor(name, expertise) {
[Link] = name;
[Link] = expertise;
}
provideService() {
return `${[Link]} provides consulting services in ${[Link]}.`;
}
}
class OracleHCMConsultant extends Consultant {
constructor(name, certification) {
super(name, "Oracle HCM");
[Link] = certification;
}
provideService() {
return `${[Link]} specializes in ${[Link]}, holding a $
{[Link]} certification, helping companies manage HR solutions.`;
}
}
const oracleConsultant = new OracleHCMConsultant("Alice", "Oracle Certified HCM
Specialist");