import java.util.Scanner; |
public class Main{ |
public static void main(String[] args) { |
Scanner scan = new Scanner(System.in); |
int n = scan.nextInt(); |
String s = scan.next(); |
if (n == 1 ) { |
BallMatch match = new FootballMatch(s); |
match.compete(); |
} |
else if (n == 2 ) { |
BallMatch match = new BasketballMatch(s); |
match.compete(); |
} |
scan.close(); |
} |
} |
abstract class BallMatch{ |
private String s; |
public BallMatch(String _s) { |
s = _s; |
} |
public String getS() { |
return s; |
} |
public final void compete() { |
checkin(); |
start(); |
play(); |
end(); |
annouceResult(); |
} |
private void checkin() { |
System.out.println( "now checking in" ); |
} |
private void start() { |
System.out.println( "now starting" ); |
} |
|
private void end() { |
System.out.println( "now ending" ); |
} |
public abstract void play(); |
public abstract void annouceResult(); |
} |
class FootballMatch extends BallMatch{ |
public FootballMatch(String _s) { |
super (_s); |
} |
public void play() { |
System.out.println( "now playing football" ); |
} |
public void annouceResult() { |
System.out.println( "now annoucing result: " + super .getS()); |
} |
} |
class BasketballMatch extends BallMatch{ |
public BasketballMatch(String _s) { |
super (_s); |
} |
public void play() { |
System.out.println( "now playing basketball" ); |
} |
public void annouceResult() { |
System.out.print( "now annoucing result: " + super .getS()); |
} |
} |