Hello to you all ,

I am attaching a HW project which i made in Eclipse 3.2 Enviorment.
It is a Cube tourney that each game consists 10 players.
Round 1 is 100 Games , each winner is sent to the SemiFinal.
than 10 Games of Semi - each winner sent to final, than final game.

The rules : until 1 or 2 players remain , the players with Max Result and Min Result in each Randomized Roll of the Polygon ( 13 faces) are out.
conditions : if MinCount + MaxCount = PlayersRemainedCount there has to be a new Roll of the Polygon to all of them and re-check conditions.
If 1 players Remains - he wins. If 2 remain , the player with the highest roll result wins.

Bugs : Duplicate names in SemiFinal and Final games , somehow the are being repeated after i reset the array of rolls and names. I have spent 5 hours to try and find it ... i didnt. i am in a pool of poo :cheesy:

Thanx , i have 30 hours to submit it for a grade .(Wrapped in ZIP File)

Yotam , Israel .

Noone's going to browse through your stuff and fix it all for you.
Copy relevant parts in code tags and show where you have problems, and people will most likely try to help.

Noone's going to browse through your stuff and fix it all for you.
Copy relevant parts in code tags and show where you have problems, and people will most likely try to help.

public static int EliminatePlayers(int max,int min,int numOfPlayers)
	{
		int killCount=0;
		int retValue=0;
		for (int i=0;i<10;i++)
		{
			if (rollArray[i]==min) 
			{
				players[i]=null;
				rollArray[i]=0;
				killCount++;
			}
			if (rollArray[i]==max) 
			{
				players[i]=null;
				rollArray[i]=0;
				killCount++;
			}
		}
		PrintEliminated();
		System.out.printf("\n ---Next Round--- \n");
		retValue=(numOfPlayers-killCount);
		return retValue;
	}
	public static String ScanForWinner(int playersLeft)
	{
		int winnerIndex=10;
		
		if (playersLeft==1) //Only 1 Player Remains as Winner
		{
		for (int i=0;i<10;i++)
			{
			if (rollArray[i]!=0) winnerIndex=i;
			}
		
		}
		// End of 1 Player Case //
		if (playersLeft==2) 		//2 Players Remain , Including Tie Break Operation
		{
			int tempMaxVal=rollArray[0];
			int maxIndex=0;
			
			for (int i=1;i<10;i++)
			{
				if (tempMaxVal<rollArray[i])
				{
					tempMaxVal=rollArray[i];
					maxIndex=i;
					
				}
			rollArray[maxIndex]=0;	
			for (int j=0;j<10;j++)
			{
				if (rollArray[j]==tempMaxVal)
				{
					while (rollArray[j]==tempMaxVal)
					{
						rollArray[j]=RollDie();
						rollArray[maxIndex]=RollDie();
						if (tempMaxVal<rollArray[j]) 
						   { winnerIndex=j; break; }
						if (tempMaxVal>rollArray[j]) 
						   { winnerIndex=maxIndex; break;}
					}
					if (tempMaxVal<rollArray[j]) 
					   { winnerIndex=j; break; }
					if (tempMaxVal>rollArray[j]) 
					   { winnerIndex=maxIndex; break;}
					
				}
			}
		}
		winnerIndex=maxIndex;
	}
			return players[winnerIndex];
}

public void GamePlay()
	{
		int maxInRoll;	 //Max Value in Round
		int minInRoll;	 //Min Value in Round
		int maxCount=0;	//Counts holding Max Value
		int minCount=0;	//Counts holding Min Value
		int playersRemainCount=10; //Players Remains InGame Count
		
		CreateRound(playersRemainCount); 	//First Round
		
		while ((playersRemainCount>2)) //Condition for GamePlay to Continue
		{
			minInRoll=findMinInArray(); 	//Finds Min in Round
			maxInRoll=findMaxInArray(); 	//Finds Max in Round
			maxCount=CountMax(maxInRoll); 	//Counts for Max
			minCount=CountMin(minInRoll); 	//Counts for Min
			System.out.printf("MinCount is %d = Min  %d , Max Count is %d = Max %d \n", minCount,minInRoll,maxCount,maxInRoll);
			if ((minCount+maxCount==playersRemainCount) && (playersRemainCount>2))
			{
				JOptionPane.showMessageDialog(null,"Abnoraml Situation \nCreating New Round\nFor Remaining Players");
				CreateRound(playersRemainCount);
				playersRemainCount=EliminatePlayers(findMaxInArray(),findMinInArray(),playersRemainCount); //Eliminates Holding Max and Min
				CreateRound(playersRemainCount); //Next Round After Abnormal Situation
			}
			else
			{
			playersRemainCount=EliminatePlayers(maxInRoll,minInRoll,playersRemainCount); //Eliminates Holding Max and Min
			CreateRound(playersRemainCount); //Next Round
			}
		}
		
		if (playersRemainCount==1)
			{	winnerPlayer=ScanForWinner(1);
				for (int j=0;j<10;j++)
					if (players[j]==winnerPlayer) 
						{ players[j]=null; rollArray[j]=0; }
			
			}      //Extract Winner			
		if (playersRemainCount==2)
			{   winnerPlayer=ScanForWinner(2);
				for (int j=0;j<10;j++)
					if (players[j]==winnerPlayer) 
						{ players[j]=null; rollArray[j]=0; }
			
			}	   //Extract Winner
		
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.