UML Diagram
![UML Diagram to JAVA code [problem 4] 1 Problem4](https://old.nurnobishanto.com/wp-content/uploads/2019/10/Problem4_UML.jpg)
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);
}
}
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
![UML Diagram to JAVA code [problem 4] 2 UML Diagram to JAVA code [problem 4] 1](https://old.nurnobishanto.com/wp-content/uploads/2019/10/Problem4_ouput.jpg)
- Best Laravel App Developer in Mirpur, Dhaka – Nurnobi Shanto
- Best Laravel App Developer in Dhaka – Nurnobi Shanto
- A Podpourri of Learning Options: Pods, Hubs, and Microschools #2
- Code to Create: Showcasing Web Development Projects
- Designing for Impact: A Portfolio of Creative Solutions