Hello guys,
I wrote a code for a "skydiving" program that randomly selects the "maneuvers" to be performed by the skydiver during his skydive. I am almost done with the program. I just need to figure out how to print non repeated maneuvers for each round. Each round may not consist of two of the same maneuvers. The program that I wrote randomly picks the maneuvers but sometimes it still prints out two of the same maneuvers for each round. I have no clue how to do this. Any ideas? Thank you very much in advance.
The following is my code.
import java.util.Scanner; import java.util.Random; ///v.0 public class Testpart2 { public static void main(String[] args) { Random randomNumbers=new Random(); Scanner input = new Scanner(System.in); // TODO Auto-generated method stub int A; int count; int roundcount; roundcount=0; String wordA = "2-Sidebody-Donut or INTER or Side Flake Donut,TEST:4-Monopod or INTER TEST:6-Stardian or INTER TEST :7-Sidebuddies or INTER TEST:9-Cat-Accordian or INTER TEST:15-Caterpilar or INTER TEST:19-Ritz or INTER or Icepick TEST:21-Zig-Zag or INTER or Margus TEST"; String[] wordAAsArray = wordA.split(":");/////Condition for class A System.out.println(" How many rounds would you like to produce? - Enter 6 or 10"); count=input.nextInt(); System.out.println(""); System.out.println("Does your team belong to the class A, (1 for YES. 0 for NO)");/////////// A class A = input.nextInt(); for (int i = 1; i <= count; i++) { roundcount++; System.out.println("-------------------------Round " +roundcount); System.out.println(); if (A==1) /////Class A { System.out.println(" Your team shold perform the following dives (A-CLASS)!"); System.out.println(); {int index = new Random().nextInt(wordAAsArray.length); String random1Word = wordAAsArray[index]; System.out.println("Dive #1 -A = " +random1Word);} {int index = new Random().nextInt(wordAAsArray.length); String random1Word = wordAAsArray[index]; System.out.println("Dive #2-A = " +random1Word);} {int index = new Random().nextInt(wordAAsArray.length); String random1Word = wordAAsArray[index]; System.out.println("Dive #3-A = " +random1Word); } } } } }