@Override voidendPlay(){ System.out.println("Football Game Finished!"); }
@Override voidinitialize(){ System.out.println("Football Game Initialized! Start playing."); }
@Override voidstartPlay(){ System.out.println("Football Game Started. Enjoy the game!"); } }
// ====================================
publicclassCricketextendsGame{
@Override voidendPlay(){ System.out.println("Cricket Game Finished!"); }
@Override voidinitialize(){ System.out.println("Cricket Game Initialized! Start playing."); }
@Override voidstartPlay(){ System.out.println("Cricket Game Started. Enjoy the game!"); } }
测试类
1 2 3 4 5 6 7 8 9 10
publicclassTemplateTest{ @Test publicvoidtest()throws Exception{ Game game = new Cricket(); game.play(); System.out.println(); game = new Football(); game.play(); } }