0% found this document useful (0 votes)
30 views2 pages

PF_Lab_08

The document contains Java code for a program that defines a course management system with classes for Course, JavaCourse, Person, Employee, and Manager. It includes methods for inputting and displaying details about courses and personnel, emphasizing object-oriented programming principles. The main method demonstrates the functionality by creating a Manager instance and collecting user input for details.

Uploaded by

gang g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

PF_Lab_08

The document contains Java code for a program that defines a course management system with classes for Course, JavaCourse, Person, Employee, and Manager. It includes methods for inputting and displaying details about courses and personnel, emphasizing object-oriented programming principles. The main method demonstrates the functionality by creating a Manager instance and collecting user input for details.

Uploaded by

gang g
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Asad Ayoob PF LAB-08.

24K-6067 Section A

TASK # 1: public static void main(String[] args) {

package com.mycompany.pf_lab; JavaCourse javaCourse = new JavaCourse("Object-Oriented


Programming", "CS101", "Room A1", 3, "Sir Zakir");
//Author: 24K6067;
javaCourse.display();
class Course {
}
protected String courseName;
}
protected String courseCode;
TASK # 2:
protected String classVenue;
package com.mycompany.pf_lab;
protected int creditHours;
//Author:24K-6067;

import java.util.Scanner;
public Course(String courseName, String courseCode, String
classVenue, int creditHours) { class Person {

this.courseName = courseName; protected String name, age, nationality, address, cnic;

this.courseCode = courseCode; public Person() { System.out.println("I am a person"); }

this.classVenue = classVenue; public void inputDetails(Scanner sc) {

this.creditHours = creditHours; System.out.print("Enter Name: "); name = sc.nextLine();

} System.out.print("Enter Age: "); age = sc.nextLine();

} System.out.print("Enter Nationality: "); nationality =


sc.nextLine();
class JavaCourse extends Course {
System.out.print("Enter Address: "); address = sc.nextLine();
private String teacherName;
do {

System.out.print("Enter CNIC (13 digits): ");


public JavaCourse(String courseName, String courseCode, String
classVenue, int creditHours, String teacherName) { cnic = sc.nextLine();

super(courseName, courseCode, classVenue, creditHours); } while (cnic.length() != 13 || !cnic.matches("\\d+"));

this.teacherName = teacherName; }

} public void displayDetails() {

public void display() { System.out.println("Name: " + name + "\nAge: " + age + "\
nNationality: " + nationality + "\nAddress: " + address + "\nCNIC: " +
System.out.println("Course Name: " + courseName);
cnic);
System.out.println("Course Code: " + courseCode);
}
System.out.println("Class Venue: " + classVenue);
}
System.out.println("Credit Hours: " + creditHours);

System.out.println("Teacher Name: " + teacherName);


class Employee extends Person {
}
protected String company, city;
}
protected int yearsWorked;
public class PF_LAB_08 {
public Employee() { System.out.println("I am an Employee"); }
Asad Ayoob PF LAB-08. 24K-6067 Section A

public void inputDetails(Scanner sc) {

super.inputDetails(sc);

System.out.print("Enter Company Name: "); company =


sc.nextLine();

System.out.print("Enter City: "); city = sc.nextLine();

System.out.print("Enter Years Worked: "); yearsWorked =


sc.nextInt(); sc.nextLine();

public void displayDetails() {

super.displayDetails();

System.out.println("Company: " + company + "\nCity: " + city +


"\nYears Worked: " + yearsWorked);

class Manager extends Employee {

private String[] employees = new String[5];

public Manager() { System.out.println("I am a Manager"); }

public void inputDetails(Scanner sc) {

super.inputDetails(sc);

System.out.println("Enter 5 employee names:");

for (int i = 0; i < 5; i++) employees[i] = sc.nextLine();

public void displayDetails() {

super.displayDetails();

System.out.println("Employees: " + String.join(", ", employees));

public class PF_LAB_08 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

Manager manager = new Manager();

manager.inputDetails(sc);

System.out.println("\n--- Details ---");

manager.displayDetails();

} }

You might also like