Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在League Manager应用程序中生成homeTeam/awayTeam对_Java_Random - Fatal编程技术网

Java 在League Manager应用程序中生成homeTeam/awayTeam对

Java 在League Manager应用程序中生成homeTeam/awayTeam对,java,random,Java,Random,我想创建随机的团队对来生成匹配。一个队不能与自己比赛,也不能进行同一场比赛。共有16支球队参加两轮比赛,每轮15场。我有一份赛程表,一份球队表和一份比赛表。我的问题是如何创建随机对? 以下是我迄今为止为此方法编写的代码: public void generateFixtures() { List<Match> fixtureMatches = new ArrayList<Match>(); for(int i = 1; i<=NUMBER_OF_

我想创建随机的团队对来生成匹配。一个队不能与自己比赛,也不能进行同一场比赛。共有16支球队参加两轮比赛,每轮15场。我有一份赛程表,一份球队表和一份比赛表。我的问题是如何创建随机对? 以下是我迄今为止为此方法编写的代码:

public void generateFixtures() {

    List<Match> fixtureMatches = new ArrayList<Match>();

    for(int i = 1; i<=NUMBER_OF_FIXTURES; i++) {
        for(int j = 0; j<4; j+=2) {
            Random rand = new Random();

            int t1 = rand.nextInt(15) + 0;
            int t2 = rand.nextInt(15) + 0;
            if(t2==t1) {
                t2 = rand.nextInt(15)+0;

            }
            SQLiteDatabase.insertInMatch(i, teams.get(t1).getTeamName(), teams.get(t2).getTeamName());

            Match m = new Match(teams.get(t1), teams.get(t2));
            fixtureMatches.add(m);
        }
        Fixture f = new Fixture(i, fixtureMatches);
        League.getInstance().fixtures.add(f);
    }
}
public void generatefactures(){
List fixtureMatches=new ArrayList();

对于(int i=1;这是一个家庭作业问题还是一个项目问题?如果是,请阅读堆栈溢出内容指南。你的问题是什么?如何实际创建随机对而不让它们重新出现????我觉得这是一个家庭作业,所以我会给你一个线索@CowboyFarnz你是如何获得指向Java 6 API的链接的?Java 7我理解…但是6?另外,它应该是
shuffle
,而不是
shuffle
=)