现在的位置: 首页 > 综合 > 正文

JAVA多态调用案例代码

2013年10月26日 ⁄ 综合 ⁄ 共 3378字 ⁄ 字号 评论关闭

/*
*title:JAVA多态调用演示类代码
*author:chinayaosir
*IDE:JDeveloper version 10.1.1
*function:excel quotesheet with warmart/kmart/cvs  sample code
*/

---------------------------------------------------------------------------------
/*
 * filename:basicqs.java
 */
package userinterfacejsp;
public class basicqs{
    public void GetExcelset( ) {
    System.out.println("pls set excel column set!");
    }

    public void GetExcelFile( ) {
    System.out.println("pls set excel file path!");
    }
    public void savetoExcel( ) {
    System.out.println("pls set excel data!");
    }     
    
}

---------------------------------------------------------------------------------
/*
* filename:warmart.java
*/
package userinterfacejsp;
class warmart extends basicqs{
    public void GetExcelset( ) {
    System.out.println("get excel column set from database table!");
    }
   public void GetExcelFile( ) {
    System.out.println("******Warmark quotesheet******************************");
    System.out.println("excel file= warmark.xls");     
    }
    public void savetoExcel( ) {
    System.out.println("write quotesheet with 120 column data and one photo!");
    System.out.println("write attahchment with 20 coloumn data");    
    System.out.println("write hangtag with 10 coloumn data");    
    }     
}
---------------------------------------------------------------------------------
/*
 * filename:kmart.java
*/
package userinterfacejsp;
class kmart extends basicqs{
    public void GetExcelset( ) {
    System.out.println("get excel column set from database table!");
    }
    
   public void GetExcelFile( ) {
    System.out.println("******Kmark quotesheet********************************");   
    System.out.println("excel file= kmark.xls");
    }
    public void savetoExcel( ) {
    System.out.println("write quotesheet with 100 column data and one photo!");
    System.out.println("write attahchment with 10 coloumn data");  
    }     
}
---------------------------------------------------------------------------------
/*
* filename:cvs.java
*/
package userinterfacejsp;
class cvs extends basicqs{
    public void GetExcelset( ) {
    System.out.println("get excel column set from database table!");
    }
    
   public void GetExcelFile( ) {
    System.out.println("******Warmark quotesheet******************************");
    System.out.println("excel file= cvs.xls");
    }
    public void savetoExcel( ) {
    System.out.println("write quotesheet with 50 column data and one photo!");
    }     
}
---------------------------------------------------------------------------------
/*
 * filename:printqs.java
 */
package userinterfacejsp;
public class printqs{  
    public void excel(basicqs temp){
                temp.GetExcelFile();
                temp.GetExcelset();
                temp.savetoExcel();
    }
    
    public static void main(String args[]) {
        printqs p=new printqs();
        kmart k=new kmart();
        warmart w=new warmart();
        cvs c=new cvs();

        p.excel(k);
        p.excel(w);
        p.excel(c);        
    }

}
---------------------------------------------------------------------------------
program run values:
******Kmark quotesheet********************************
excel file= kmark.xls
get excel column set from database table!
write quotesheet with 100 column data and one photo!
write attahchment with 10 coloumn data
******Warmark quotesheet******************************
excel file= warmark.xls
get excel column set from database table!
write quotesheet with 120 column data and one photo!
write attahchment with 20 coloumn data
write hangtag with 10 coloumn data
******Warmark quotesheet******************************
excel file= cvs.xls
get excel column set from database table!
write quotesheet with 50 column data and one photo!

抱歉!评论已关闭.