Advertisement
Sajib_Ahmed

Untitled

Apr 14th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1.  
  2. package fall2017;
  3.  
  4. /**
  5.  *
  6.  * @author sajib
  7.  */
  8. public class Person {
  9. int age;
  10.  
  11.     public Person(int age) {
  12.         this.age = age;
  13.     }
  14.    
  15.  
  16.    
  17. }
  18.    
  19.  
  20.  
  21. package fall2017;
  22.  
  23. /**
  24.  *
  25.  * @author sajib
  26.  */
  27. public interface ClassRoom {
  28.    
  29.     public void teaching();
  30.     public void reading();
  31.     public void testing();
  32. }
  33. /*
  34.  * To change this license header, choose License Headers in Project Properties.
  35.  * To change this template file, choose Tools | Templates
  36.  * and open the template in the editor.
  37.  */
  38. package fall2017;
  39.  
  40. /**
  41.  *
  42.  * @author sajib
  43.  */
  44. public class Student extends Person implements ClassRoom{
  45.  
  46.    String id;
  47.    float gpa;
  48.  
  49.     public Student(String id, float gpa)
  50.     {
  51.         super(18);
  52.         this.id = id;
  53.         this.gpa = gpa;
  54.     }
  55.  
  56.     public float getGpa() {
  57.         return gpa;
  58.     }
  59.  
  60.     public void teaching() {
  61.         System.out.println("Learn from teacher");
  62.     }
  63.  
  64.    
  65.     public void reading() {
  66.         System.out.println("read from book");
  67.     }
  68.  
  69.    
  70.     public void testing() {
  71.         System.out.println("testing yourself");
  72.     }
  73.    
  74. }
  75. /*
  76.  * To change this license header, choose License Headers in Project Properties.
  77.  * To change this template file, choose Tools | Templates
  78.  * and open the template in the editor.
  79.  */
  80. package fall2017;
  81.  
  82. /**
  83.  *
  84.  * @author sajib
  85.  */
  86. public class Teacher extends Person implements ClassRoom {
  87.     String title;
  88.  
  89.     public Teacher(String title) {
  90.         super(25);
  91.         this.title = title;
  92.        
  93.     }
  94.    
  95.     public void teaching() {
  96.         System.out.println("teaching");
  97.     }
  98.  
  99.    
  100.     public void reading() {
  101.         System.out.println("reading");
  102.     }
  103.  
  104.  
  105.     public void testing() {
  106.         System.out.println("testing student");
  107.     }
  108. }
  109.  
  110. package fall2017;
  111.  
  112. /**
  113.  *
  114.  * @author sajib
  115.  */
  116. public class Main {
  117.     public static void main(String[] args)
  118.     {
  119.         Student obj=new Student("181-15-10874",4);
  120.         Teacher obj1=new Teacher("Fakar jaman");
  121.         System.out.println("Student");
  122.         System.out.println("age :"+obj.age+"\nID :"+obj.id+"\ngpa"+obj.gpa);
  123.         obj.teaching();
  124.         obj.reading();
  125.          obj.testing();
  126.          System.out.println("Teacher");
  127.          System.out.println("age :"+obj1.age+"\nTitle :"+obj1.title);
  128.          obj1.teaching();
  129.         obj1.reading();
  130.          obj1.testing();
  131.        
  132.     }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement