Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.22 KB | None | 0 0
  1. /**
  2.  * @(#)Team.java
  3.  *
  4.  *
  5.  * @author
  6.  * @version 1.00 2010/4/30
  7.  */
  8. import java.util.*;
  9.  
  10. public class Team {
  11.        
  12.     private String team;
  13.     private String name;
  14.     private int BallPosition=0;
  15.     private int teamscore=0;
  16.     private int pass = (int)(Math.random()*2+1);
  17.     private int defendershoot = (int)(Math.random()*10+1);
  18.     private int midshoot = (int)(Math.random()*10+1);
  19.     private int strikershoot = (int)(Math.random()*2+1);
  20.    
  21.     public void ReadTeam() {
  22.        
  23.         Scanner scan = new Scanner(System.in);
  24.        
  25.         System.out.print("Player: Where is your team from? ");
  26.         team=scan.nextLine();
  27.         System.out.print("Player: What is their name? ");
  28.         name=scan.nextLine();
  29.  
  30.     }
  31.    
  32.     public void SetTeam(){
  33.        
  34.         System.out.println(team.toString()+" "+name.toString());
  35.     }
  36.    
  37.     public void BallPlayer(){
  38.        
  39.         if(BallPosition==0){
  40.             System.out.println("Defender");
  41.         }
  42.         else if(BallPosition==1){
  43.             System.out.println("Midfielder");
  44.         }
  45.         else if(BallPosition==2){
  46.             System.out.println("Striker");
  47.         }
  48.        
  49.     }
  50.  
  51.     public void pass(){
  52.        
  53.         if(pass==1){
  54.             if(BallPosition<3){
  55.             System.out.println("The pass was succesfull");
  56.             BallPosition++;
  57.             }
  58.             else if(BallPosition>2){
  59.             BallPosition=2;
  60.             System.out.println("The pass was succesfull");
  61.             }
  62.         }
  63.         else if(pass==2){
  64.             System.out.println("The pass was fail!!!! Team 2 now have the ball");
  65.             BallPosition=0;
  66.         }
  67.        
  68.    }
  69.    
  70.     public void score(){
  71.        
  72.         if(BallPosition==0){
  73.             if(defendershoot==1){
  74.                 System.out.println("GOAL!!!!!");
  75.                 teamscore++;
  76.             }
  77.             else{
  78.                 System.out.println("Miss!!!!!");
  79.             }
  80.         }
  81.         else if(BallPosition==1){
  82.             if(midshoot==1||midshoot==2||midshoot==3){
  83.                 System.out.println("GOAL!!!!!");
  84.                 teamscore++;
  85.             }
  86.             else{
  87.                 System.out.println("Miss!!!!!");
  88.             }
  89.         }
  90.         else if(BallPosition==2){
  91.             if(strikershoot==1){
  92.                 System.out.println("GOAL!!!!!");
  93.                 teamscore++;
  94.             }
  95.             else{
  96.                 System.out.println("Miss!!!!!");
  97.             }
  98.            
  99.            
  100.         }
  101.    }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement