/*
 * @topic T11360 Cloneable class demo III
 * @brief main( ) uses Product copy constructor -- deep copy
*/

package products;

public class ProductsMain {

    public static void main(String[] args) {
        Product book = new Product( 123, "Horror", 5.95 );
        // no longer needs try-catch block
        //try {
            // before:
            // Product book2 = ( Product ) book.clone();
            Product book2 = new Product( book ); // use copy constructor
            if ( book.getDescription() == book2.getDescription() ) {
                System.out.println( "The copy is shallow" );
            } else {
                System.out.println( "The copy is deep" );
            }
            book2.setDescription( "Computers" );
            System.out.println( book.getDescription() );
            System.out.println( book2.getDescription() );

        //} catch ( CloneNotSupportedException ex ) {
        //}
    }//main

}//class ProductsMain