/* * @topic T11362 Cloneable class demo III * @brief Cloneable class Product -- deep copy with copy constructor */ package products; public class Product /*implements Cloneable*/ { private int code; private StringWrapper title; // aggregates instance of another class private double price; // constructors public Product( int code, String description, double price) { this.code = code; title = new StringWrapper( description ); this.price = price; } // copy constructor public Product( Product another ) { this.code = another.code; title = new StringWrapper( new String( another.getDescription() ) ); this.price = another.price; } // operations /* @Override public Object clone() throws CloneNotSupportedException { // invoke Object.clone() return super.clone(); } */ public String getDescription() { return title.getText(); } public void setDescription( String descr ) { title.setText(descr); } }//class Product