Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- abstract class Ball {
- private int x;
- private int y;
- private Random r = new Random();
- public Ball(int a,int b){
- x=a;
- y=b;
- }
- public void play(Ball b) throws outException,goalException,cornerException {
- int x = r.nextInt(101);
- int y = r.nextInt(51);
- if(y==0 || y==50)
- throw new outException();
- else if ((x==0 || x==100)&&(y>=20 && y<=30))
- throw new goalException();
- else if ((x==0 || x==100)&&((y<0 && y<20) || (y<30 && y<50)))
- throw new cornerException();
- }
- }
- class outException extends Exception {
- public outException(){
- super("That's a side throw!\n");
- }
- }
- class cornerException extends Exception {
- public cornerException() {
- super("Corner kick! Let's see what they're up to!!\n");
- }
- }
- class goalException extends Exception {
- public goalException() {
- super("Look at that goal! Great finish, great precission, great player! Let's see the replay!\n");
- }
- }
- class Game {
- private String team1;
- private String team2;
- private int score;
- private int outs;
- private int corners;
- public Game(String team1, String team2) {
- this.team1 = team1;
- this.team2 = team2;
- }
- public String toString() {
- return "The score is: " + score + " \n We had " + outs + " outs in this game\n" + "And we had " + corners + " corners in this game\n";
- }
- public void playGame() {
- for(int i = 0; i < 2000; i++)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement