Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fall2017;
- /**
- *
- * @author sajib
- */
- public class Person {
- int age;
- public Person(int age) {
- this.age = age;
- }
- }
- package fall2017;
- /**
- *
- * @author sajib
- */
- public interface ClassRoom {
- public void teaching();
- public void reading();
- public void testing();
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package fall2017;
- /**
- *
- * @author sajib
- */
- public class Student extends Person implements ClassRoom{
- String id;
- float gpa;
- public Student(String id, float gpa)
- {
- super(18);
- this.id = id;
- this.gpa = gpa;
- }
- public float getGpa() {
- return gpa;
- }
- public void teaching() {
- System.out.println("Learn from teacher");
- }
- public void reading() {
- System.out.println("read from book");
- }
- public void testing() {
- System.out.println("testing yourself");
- }
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package fall2017;
- /**
- *
- * @author sajib
- */
- public class Teacher extends Person implements ClassRoom {
- String title;
- public Teacher(String title) {
- super(25);
- this.title = title;
- }
- public void teaching() {
- System.out.println("teaching");
- }
- public void reading() {
- System.out.println("reading");
- }
- public void testing() {
- System.out.println("testing student");
- }
- }
- package fall2017;
- /**
- *
- * @author sajib
- */
- public class Main {
- public static void main(String[] args)
- {
- Student obj=new Student("181-15-10874",4);
- Teacher obj1=new Teacher("Fakar jaman");
- System.out.println("Student");
- System.out.println("age :"+obj.age+"\nID :"+obj.id+"\ngpa"+obj.gpa);
- obj.teaching();
- obj.reading();
- obj.testing();
- System.out.println("Teacher");
- System.out.println("age :"+obj1.age+"\nTitle :"+obj1.title);
- obj1.teaching();
- obj1.reading();
- obj1.testing();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement