Good evening everyone, I just wanted to start by saying that I have been searching though this (and a few other) site for the last 3 hours to no avail, i have read every post i could find in regards to my topic and either it did not apply or i couldn't quite understand what was happening. I have my program running and will post it as well, but my first issue is that i cant seem to get the random number generator to discard a choice once it has been made. (will describe below) my second issue is that there can only be one six point round per competition, and i cant seem to figure out how to limit it only to one with the specific constraints of a 6 point round. The program is designed to simulate picking the jumps for a skydiving competition, there are three separate competitions (A,AA,AAA)(levels of difficulty, certain moves do not appear A or AA, AAA is all inclusive) that the user can pick from as well as whether the individual competition will be 6 or 10 rounds (A will always be 6 rounds). Once the user has picked the competition and number of rounds, the program is supposed to output the individual moves to be completed for each round as well as the points for the round (does this for all 6 or 10 rounds of the competition). here is where my first issue lies, once a move is picked, it cannot be used again for the rest of the competition, i cannot for the life of me figure out how to do this. moving on, there are two separate categories for scoring, the numbered moves (1-22 in my program) and the lettered moves (23 and up), the numbered are worth 2 points and the lettered are worth 1. each round is 5 or 6 points, the issue i am having with this is for there to be a 6 point round, it can only be made up of 3 numbered moves, no other combination would be acceptable; and to add to that, there can only be one six point round in the entirety of the competition. I hope i explained it well enough for all of you to understand, but please let me know if that is not the case. i appreciate your time, and i look forward to hearing from you.
import java.util.Random;
import java.util.Scanner;
import java.util.ArrayList;
public class Skydiving1
{
public static void main(String[] args)
{
Random myRandom = new Random();
Scanner inputClass = new Scanner(System.in);
ArrayList< Boolean > formationRound = new ArrayList< Boolean >();
int formation = 0;
int point = 0;
int jumpClass = 0;
int roundNumber = 0;
int round = 1;
boolean pickedRandom = false;
boolean A = false;
boolean AA = false;
boolean AAA = false;
for( int i = 0; i < 39; i++)
{
formationRound.add( false );
}
formationRound.set( 0, true );
System.out.print( "1: Class A\n2: Class AA\n3: Class AAA\n");
System.out.print( " Enter number 1-3 depending on class:\n" );
jumpClass = inputClass.nextInt();
if( jumpClass == 1 )
{
A = true;
round = 6;
formationRound.set( 1, true );
formationRound.set( 3, true );
formationRound.set( 5, true );
formationRound.set( 8, true );
formationRound.set( 10, true );
formationRound.set( 11, true );
formationRound.set( 12, true );
formationRound.set( 14, true );
formationRound.set( 16, true );
formationRound.set( 17, true );
formationRound.set( 18, true );
formationRound.set( 20, true );
formationRound.set( 22, true );
}
else
{
System.out.print( "6 or 10 rounds?\n");
round = inputClass.nextInt();
if( jumpClass == 2 )
{
AA = true;
formationRound.set( 3, true );
formationRound.set( 5, true );
formationRound.set( 10, true );
formationRound.set( 12, true );
formationRound.set( 16, true );
formationRound.set( 17, true );
}
else
{
AAA = true;
}
}
for(int i=0; i < round; i++ )
{
System.out.printf("\nRound %d:\n", i+1);
point = 0;
while(point < 5)
{
pickedRandom=false;
formation = myRandom.nextInt(38) + 1;
while(formation == 31)
{
formation = myRandom.nextInt(38) + 1;
}
if(point == 4 && pickedRandom && formation < 23 )
{
while(formation < 23)
formation = myRandom.nextInt(38) + 1;
}
if(formation < 23)
{
point+=2;
}
else
{
pickedRandom=true;
point++;
}
formationRound.set( formation, true );
if(formation > 22)
System.out.printf(" %s %s ",randomLetter(formation), formationName(formation));
else
System.out.printf(" %d %s", formation, formationName(formation));
}
System.out.println();
System.out.printf( " %s \n", point );
}
}
public static String formationName(int g)
{
switch(g)
{
case 1: return "Snowflake Snowflake";
case 2: return "Sidebody Donut Sidebody Donut";
case 3: return "Side Flake Opal Turt";
case 4: return "Monopod Monopod";
case 5: return "Opal Opal";
case 6: return "Stardian Stardian";
case 7: return "Sidebuddies sidebuddies";
case 8: return "CandianTree CandianTree";
case 9: return "CatsAccordian CatsAccordian";
case 10: return "Dimond Bunyid";
case 11: return "Photon Photon";
case 12: return "Bundy Bundy";
case 13: return "Offset Spinner";
case 14: return "Bipole Bipole";
case 15: return "Catipilar Catipilar";
case 16: return "Compressed Box";
case 17: return "DanishTree Murphy";
case 18: return "Zircon Zircon";
case 19: return "Ritz Icepick";
case 20: return "Piver Viper";
case 21: return "ZigZag Marguis";
case 22: return "ZigZag Marguis";
case 23: return "Unipod";
case 24: return "Stairstep Diamond";
case 25: return "MurphyFlake";
case 26: return "Yuan";
case 27: return "Meeker";
case 28: return "Open Accordian";
case 29: return "Cataccord";
case 30: return "Bow";
case 31: return "";
case 32: return "Donut";
case 33: return "Hook";
case 34: return "Adder";
case 35: return "Star";
case 36: return "Crank";
case 37: return "Satelit";
case 38: return "Sidebody";
case 39: return "Phalanx";
default: return"";
}
}
public static String randomLetter (int f)
{
if (f>22)
switch (f)
{
case 23: return "A";
case 24: return "B";
case 25: return "C";
case 26: return "D";
case 27: return "E";
case 28: return "F";
case 29: return "G";
case 30: return "H";
case 31: return "I";
case 32: return "J";
case 33: return "K";
case 34: return "L";
case 35: return "M";
case 36: return "N";
case 37: return "O";
case 38: return "P";
case 39: return "";
default: return "";
}
return"";
}
}
Aucun commentaire:
Enregistrer un commentaire