Created
November 23, 2019 17:03
-
-
Save inan-mahmud/40672933db5709ccfd9307862a7553af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class Main { | |
public static void main(String[] args) { | |
Person mPerson = new Person("Sayeed","Robin","0134234432","[email protected]"); | |
mPerson.printName(); | |
System.out.println(mPerson.getEmailAddress()); | |
Person nPerson = new Person(); | |
nPerson.printName(); | |
Student student = new Student(); | |
String name = student.getLastName(); | |
student.printName(); | |
System.out.println(student.getFirstName()); | |
Teacher teacher = new Teacher("shojib","arif","21132912","gdfdsfsdf","lecturer","1"); | |
teacher.printName(); | |
String des = teacher.getDesignation(); | |
System.out.println(des); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class Person { | |
private String firstName; | |
private String lastName; | |
private String phoneNo; | |
private String emailAddress; | |
public Person(String firstName, String lastName, String phoneNo, String emailAddress) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
this.phoneNo = phoneNo; | |
this.emailAddress = emailAddress; | |
} | |
public Person() { | |
} | |
public String getFirstName() { | |
return this.firstName; | |
} | |
public void setFirstName(String firstName) { | |
this.firstName = firstName; | |
} | |
public String getLastName() { | |
return lastName; | |
} | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
public String getPhoneNo() { | |
return phoneNo; | |
} | |
public void setPhoneNo(String phoneNo) { | |
this.phoneNo = phoneNo; | |
} | |
public String getEmailAddress() { | |
return emailAddress; | |
} | |
public void setEmailAddress(String emailAddress) { | |
this.emailAddress = emailAddress; | |
} | |
public void printName(){ | |
System.out.println(firstName+" "+lastName); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class Student extends Person { | |
private String rollNo; | |
private String schoolName; | |
private String classLevel; | |
private String sectionNo; | |
public Student(String firstName, String lastName, String phoneNo, String emailAddress, String rollNo, String schoolName, String classLevel, String sectionNo) { | |
super(firstName, lastName, phoneNo, emailAddress); | |
this.rollNo = rollNo; | |
this.schoolName = schoolName; | |
this.classLevel = classLevel; | |
this.sectionNo = sectionNo; | |
} | |
public Student() { | |
} | |
public String getRollNo() { | |
return rollNo; | |
} | |
public void setRollNo(String rollNo) { | |
this.rollNo = rollNo; | |
} | |
public String getSchoolName() { | |
return schoolName; | |
} | |
public void setSchoolName(String schoolName) { | |
this.schoolName = schoolName; | |
} | |
public String getClassLevel() { | |
return classLevel; | |
} | |
public void setClassLevel(String classLevel) { | |
this.classLevel = classLevel; | |
} | |
public String getSectionNo() { | |
return sectionNo; | |
} | |
public void setSectionNo(String sectionNo) { | |
this.sectionNo = sectionNo; | |
} | |
@Override | |
public void printName() { | |
System.out.println("Student's name is : "+getFirstName()+" "+getLastName()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
public class Teacher extends Person { | |
private String designation; | |
private String rank; | |
public Teacher(String firstName, String lastName, String phoneNo, String emailAddress, String designation, String rank) { | |
super(firstName, lastName, phoneNo, emailAddress); | |
this.designation = designation; | |
this.rank = rank; | |
} | |
@Override | |
public void printName() { | |
System.out.println(getFirstName()+" is a teacher"); | |
} | |
public String getDesignation() { | |
return designation; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment