package jp.ne.naokiur.design.pattern.composite;

public class App {

    public static void main(String[] args) {
        Carbon firstCarbon = new Carbon();
        firstCarbon.bond(new Hydrogen());
        firstCarbon.bond(new Hydrogen());
        firstCarbon.bond(new Hydrogen());

        Carbon secondCarbon = new Carbon();
        secondCarbon.bond(new Hydrogen());
        secondCarbon.bond(new Hydrogen());
        secondCarbon.bond(new Hydrogen());
        secondCarbon.bond(firstCarbon);

        System.out.println(secondCarbon.createChemicalFormula());
    }
}

@@ -122,22 +122,17 @@
  Carbon 
-firstC
+c
 arbon = 
@@ -145,38 +145,33 @@
 rbon();%0A        
-firstC
+c
 arbon.bond(new H
@@ -182,38 +182,33 @@
 gen());%0A        
-firstC
+c
 arbon.bond(new H
@@ -227,22 +227,17 @@
         
-firstC
+c
 arbon.bo
@@ -272,22 +272,21 @@
  Carbon 
-second
+basic
 Carbon =
@@ -300,38 +300,37 @@
 rbon();%0A        
-second
+basic
 Carbon.bond(new 
@@ -342,38 +342,37 @@
 gen());%0A        
-second
+basic
 Carbon.bond(new 
@@ -384,38 +384,37 @@
 gen());%0A        
-second
+basic
 Carbon.bond(new 
@@ -434,22 +434,21 @@
         
-second
+basic
 Carbon.b
@@ -455,14 +455,9 @@
 ond(
-firstC
+c
 arbo
@@ -492,14 +492,13 @@
 tln(
-second
+basic
 Carb

Optimize name. Structual Formula need circulation but Composite pattern is not suitable.