ex1)
public class A{
private B b
}
public class B{
private String f1;
private int f2;
}
ex2)
public class Test1{
private Test2 t2;
public Test3 method1(){
return new Test3;
}
}
public class Test2{
private int f1;
}
public class Test3{
private String str;
public String getStr();
return str;
}
public void setStr(String str){
this.str = str;
}
ex3)
public abstract class Parent{
public void parentMethod1(){}
protected abstract void print();
}
public class Child extends Parent{
private String name;
public void childMethod(){}
protected void print(){}
}
ex4)
public abstract class Shape{
public void draw(){}
public void erase(){}
public int getLength(){
return length;
}
protected abstract double getArea();
}
public class Triangle extends Shape implements Resizable{
public boolean isEquilateral(){}
protected double getAtrea(){}
public void resize(){}
}
public interface Resizable{
public abstract void resize();
}
public class Rectangle extends Shape implements Resizable{
public boolean isSquare()
protected double getAtrea(){}
public void resize(){}
}
ex5)
public class ClassRoom{
private Student std;
private ClassRoom(Student std){
this.std = std;
}
}
public class Student{
private String name;
private int age;
}
ex6)
public class Library{
private Book book;
public Library(){
this.book = new Book;
}
}
public class Book{
private String title;
private String author;
}
ex7)
public class Shop{
private Projuct product;
private Employee emp;
public Shop(Projuct p){
this.product = p;
this.emp = new Employee();
}
}
public class Employee{
private String name;
}
public class Product{
private String pName;
private int price;
}
ex8)
public abstract class Coffee{
public String beans;
}
public class CafeLatte extends Coffee{
private String temperature;
private int price;
public void drink(){
Option opt = new Option();
}
}
public class Option{
private int shot;
private Stirng ice;
pricate int syrup;
}
public class Cafe[
private String name;
private String address;
private CafeLatte latte;
public Cafe(CafeLatte latte){
this.latte = latte;
}
}