I am trying to make a simple tournament simulator that calls for the user to input team names and ability of the team from 1-100 and then plays a round robin tournament between them where each team plays the other twice. The games are played by generating a random number from 0-sum of the two teams abilities and if it is below the first team that team is the winner.
import java.util.Scanner; public class tourney { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Please enter the number of teams: "); int teamsCount = input.nextInt(); for (int i = 0; i < teamsCount; ++i) { System.out.print("Please enter the name of the team (without spaces): "); String name = input.next(); System.out.print("Please enter the strength of the team (1 - 100): "); int strength = input.nextInt(); } } } class Team { // The name of the team private String name; // The strength of the team private int strength; // Constructor, which takes name and strength of the team Team(String name, int strength) { this.name = name; this.strength = strength; } // The method to get the name of the team public String getName() { return name; } // Get the strength of the team public int getStrength() { return strength; } // Play a game between the current team (the one, for which this method is called) // In other words the first team is this team, the other team is provided as a parameter public boolean playGame(Team anotherTeam) { } }
I realize I will have to make a whole other class for tournament but right now I am struggling on just playing the games. I figure I will use a (int)(Math.random * (ability1stteam + ability2ndteam). From the class Team, I understand how to call the first values but will I need to create a whole other class to be able to call the team name and strength from the other team or how would I go about this?
Thanks for any help that can be provided.