Thanks to visit codestin.com
Credit goes to www.scribd.com

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

Nithin OOP Assignment

Uploaded by

nifarabiya21
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)
8 views2 pages

Nithin OOP Assignment

Uploaded by

nifarabiya21
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/ 2

import java.util.

ArrayList;
import java.util.List;

class User {
private String name;
private String mail;
private String uid;

public User(String name, String mail, String uid) {


this.name = name;
this.mail = mail;
this.uid = uid;
}

public String getName() {


return name;
}

public String getMail() {


return mail;
}

public String getUid() {


return uid;
}

public void setName(String name) {


this.name = name;
}

public void setMail(String mail) {


this.mail = mail;
}

public void setUid(String uid) {


this.uid = uid;
}
}

class Instructor extends User {


private String expert;
private List<String> courseList;

public Instructor(String name, String mail, String uid, String expert) {


super(name, mail, uid);
this.expert = expert;
courseList = new ArrayList<>();
}

public String getExpert() {


return expert;
}

public void setExpert(String expert) {


this.expert = expert;
}

public void addCourse(String cname) {


courseList.add(cname);
}

public void showDetails() {


System.out.println("----- Instructor Info -----");
System.out.println("Name: " + getName());
System.out.println("Email: " + getMail());
System.out.println("User ID: " + getUid());
System.out.println("Expertise: " + expert);
System.out.println("Courses Taken:");
for (String c : courseList) {
System.out.println("- " + c);
}
}
}

public class Main {


public static void main(String[] args) {
Instructor inst = new Instructor("Nithin", "[email protected]", "CB2025", "AI & ML")

inst.setMail("[email protected]");

inst.addCourse("Intro to ML");
inst.addCourse("Python for Automation");
inst.addCourse("DL with AI");

inst.showDetails();
}
}

You might also like