abstract class SonyProduct{
	String type;
	double price;
	abstract void printInfo();
}
class SonyTV extends SonyProduct{
	void printInfo(){
		System.out.println("The SonyTV:type-"+type+",price-"+price);
	}
}
class SonyCamera extends SonyProduct{
	void printInfo(){
		System.out.println("The SonyCamera:type-"+type+",price-"+price);
	}
}
public class Example12_1{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.println("Please input product:");
		String className = scan.next();                              //输入类名
		System.out.println("Please input type of product:");
		String type = scan.next();                                   //输入种类
		System.out.println("Please input price of product:");
		double price = scan.nextDouble();                            //输入价格
		try{
			Class c = Class.forName(className);                    //加载类
			SonyProduct sonyProduct = (SonyProduct)c.newInstance();  //创建被加载的类的对象
			sonyProduct.type = type;
			sonyProduct.price = price;
			sonyProduct.printInfo();
		}catch(ClassNotFoundException e){
			System.out.println(e);
		}catch(InstantiationException e){
			System.out.println(e);
		}catch(IllegalAccessException e){
			System.out.println(e);
		}
	 }
}
