Important Concepts of Object-Oriented system (Part I)

//Report.java
package com.thirstybrain.Model;
import java.util.List;
public interface Report {
List<Object> run(ReportContext reportContext);
}
//ReportContext.java
package com.thirstybrain.Model;
public class ReportContext {
}
//EmployeeReport.java
package com.thirstybrain.Model;
import java.util.List;
public class EmployeeReport implements Report{
@Override
public List<Object> run(ReportContext reportContext{
System.out.println("Executing EmployeeReport");
return null;
}
}
//SalaryReport.java
package com.thirstybrain.Model;
import java.util.List;
public class SalaryReport implements Report {
@Override
public List<Object> run(ReportContext reportContext) {
System.out.println("Executing SalaryReport");
return null;
}
}
//Employee.java
import com.thirstybrain.Model.EmployeeReport;
import com.thirstybrain.Model.Report;
import com.thirstybrain.Model.ReportContext;
import com.thirstybrain.Model.SalaryReport;
public class Employee{public static void main(String[] args) {ReportContext reportContext =new ReportContext();
Report ereport = new EmployeeReport();
ereport.run(reportContext);
//Output : Executing EmployeeReport
Report sreport = new SalaryReport();
sreport.run(reportContext);
//Output : Executing SalaryReport
}
}
public class Person  {
private int age;
private String name;
public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getName() {
// getter can restrict the code without displaying
// data to the user
if(condition){//restricted user check
return null;
//returning null because the user is not
//supposed to view the data
}
return name;
}
}
public class Person  {
private int age;
private String name;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}

public String getName() {
// getter can restrict the code without displaying
// data to the user
if(condition){//restricted user check
return null;
//returning null because the user
// is not supposed to view the data
}
return name;
}
public void setName(string name) {
this.name = name;
}
}
public class Employee {public static void main(String[] args) {Person personObj=new Person();
personObj.setName(“Prabhat”);
personObj.setAge(“40”);
System.out.println(“Name : ”+ personObj.getName() + “ Age : ”+ personObj.getAge())
}
}

--

--

--

Technical Consultant | Passionate about exploring new Technology | Cyber Security Enthusiast | Technical Blogger | Problem Solver

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Cache, cache everywhere Part 2

Hello, 2017!

Running playlist builder ft. DJ Spotify recs

Do you have to memorize Programming?

Developing our own operating system

Managing Dependency and Module Versioning Using Go Modules

Create custom Listener and register it to a PDB

CI/CD Basics — Why and When?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kumar Shivam

Kumar Shivam

Technical Consultant | Passionate about exploring new Technology | Cyber Security Enthusiast | Technical Blogger | Problem Solver

More from Medium

How developers deal with the date and time in Java

Getting it with Git

JAVA FULL STACK DEVELOPMENT

Collection In JAVA