0% found this document useful (0 votes)
21 views3 pages

Object Oriented Programming

Uploaded by

mainulamin0177
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)
21 views3 pages

Object Oriented Programming

Uploaded by

mainulamin0177
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/ 3

Java Code for University Academic System:

// Interface for Teachable


interface Teachable {
void teachCourse();
}

// Interface for Attendable


interface Attendable {
void attendCourse();
}

// Abstract class Person


abstract class Person {
String name;
String id;

public Person(String name, String id) {


this.name = name;
this.id = id;
}

abstract void showInfo();


}

// Faculty abstract class implementing Teachable


abstract class Faculty extends Person implements Teachable {
public Faculty(String name, String id) {
super(name, id);
}
}

// Full-time faculty class


class FullTimeFaculty extends Faculty {
public FullTimeFaculty(String name, String id) {
super(name, id);
}

public void teachCourse() {


System.out.println(name + " (Full-Time Faculty) is teaching a course.");
}

public void showInfo() {


System.out.println("Faculty Name: " + name + ", ID: " + id);
}
}

// Student abstract class implementing Attendable


abstract class Student extends Person implements Attendable {
public Student(String name, String id) {
super(name, id);
}
}
// Undergraduate student class
class UndergraduateStudent extends Student {
public UndergraduateStudent(String name, String id) {
super(name, id);
}

public void attendCourse() {


System.out.println(name + " (Undergraduate Student) is attending a course.");
}

public void showInfo() {


System.out.println("Student Name: " + name + ", ID: " + id);
}
}

// Course class
class Course {
String title;
boolean isOnline;

public Course(String title, boolean isOnline) {


this.title = title;
this.isOnline = isOnline;
}

public void showCourseType() {


System.out.println("Course Title: " + title + " - " + (isOnline ? "Online" :
"Offline"));
}
}

// Main class
public class UniversityAcademicSystem {
public static void main(String[] args) {
// Creating objects using your given data
Faculty faculty = new FullTimeFaculty("Nazifa Tasnim Hia", "F001");
Student student = new UndergraduateStudent("Mainul Amin", "241014034");
Course course = new Course("Object Oriented Programming", true);

// Showing information and demonstrating relationships


faculty.showInfo();
faculty.teachCourse();

student.showInfo();
student.attendCourse();

course.showCourseType();
}
}

Program Output:
Faculty Name: Nazifa Tasnim Hia, ID: F001
Nazifa Tasnim Hia (Full-Time Faculty) is teaching a course.
Student Name: Mainul Amin, ID: 241014034
Mainul Amin (Undergraduate Student) is attending a course.
Course Title: Object Oriented Programming - Online

You might also like