Table of Contents

4 1 vote
Rate this Post
65

UML Diagram

Problem4
Problem4

Address class java code

public class Address {
	private String city;
	private String country;

	public Address(String city,String country)
	{
		this.city=city;
		this.country=country;
	}
	public void display()
	{
		System.out.println("City :"+city+"\n"+"Country :"+country);
		
	}
}

Person class java code


public class Person {
	
	protected String name;
	protected String phone;
	Address address;
	public Person(String name,String phone,Address address)
	{
		this.name=name;
		this.phone=phone;
		this.address=address;
	}
	
	public void display()
	{
		System.out.println("\nName :"+name);
		System.out.println("Phone"+phone);
		address.display();
	}

}

PersonMain class java code


public class PersonMain {
	public static void main(String[] args)
	{
		Address ads = new Address("Dhaka","Bangladesh");
		Teacher tr = new Teacher("Rafiqul Islam","017****85",ads,"Professor");
		Student st = new Student("Nurnobi Hosen","01770634816",ads,"183-15-11820",3.25);
		
		tr.display();
		st.display();
	}

}

Student class java code


public class Student extends Person{
	private String studID ;
	private double cgpa;
	
	public Student(String name,String phone,Address address,String studID,double cgpa)
	{
		super(name,phone,address);
		this.studID=studID;
		this.cgpa=cgpa;
	}
	public void display()
	{
		super.display();
		System.out.println("Student ID:"+studID);
		System.out.println("CGPA :" +cgpa);
	}

}

Teacher class java code


public class Teacher extends Person {
	
	private String designation;

	public Teacher(String name,String phone,Address address,String designation)
	{
		super(name,phone,address);
		this.designation=designation;
	}
	public void display()
	{
		super.display();
		System.out.println("Techer Designation :"+designation);
	}
}

output

output
4 1 vote
Rate this Post
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Share on whatsapp
WhatsApp
Share on email
Email
Md. Nurnobi Hosen
Md. Nurnobi Hosen

Student of Computer Science and Engineering at Daffodil International University,Main Campus ,Dhanmondi.
Web and App Developer also expart of wordpress customization

All Blog Posts »
Subscribe
Notify of
guest
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
sdfdsf
sdfdsf
May 9, 2020 10:07 AM
Rate this Post :
     

Nice post

barbie princess and the pauper ost free lyrics
barbie princess and the pauper ost free lyrics
January 25, 2020 4:20 PM

Excellent post. Keep writing such kind of info on your site. Im really impressed by it. а

2
0
Would love your thoughts, please comment.x
()
x