Solved

linking code together

Posted on 2004-03-26
5
211 Views
Last Modified: 2012-05-04
The numbers that are generated through this code needs to go into an arraylist in the same order. I have to be able to have each number to be associated to an audio file which are in a hashmap linked to a checkbox. I have the code for the hashmap to checkboxs if needed


import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import java.lang.*;



public class TestIt {
    public static void main(String[] args) {
        printRows();
   }

// Generate numbers fir training

static void printRows() {
    final int INDEX_LIMIT = 8;
          final int BATCH_LENGTH_LIMIT = 8;
    final int BATCH_SIZE = 4;
    final int NUM_BATCH_GROUPS = 4;
    int batchLength = 4;
          // Disallow duplicates by using a Set
    Set numbers = new HashSet();
    for (int batchGroup = 0; batchGroup < NUM_BATCH_GROUPS; batchGroup++) {
               // Add numbers if more needed
      while (numbers.size() < batchLength && batchLength < BATCH_LENGTH_LIMIT) {
        numbers.add(new Integer((int)(Math.random()  * INDEX_LIMIT) + 1));
      }
      for (int batchSize = 0; batchSize < BATCH_SIZE; batchSize++) {
        java.util.List list = new ArrayList(numbers);
                    // Shuffle and print
        Collections.shuffle(list);
        System.out.println(list);
      }
      batchLength++;
      System.out.println();
    }
  }  
}


// Checkboxs to audio files Audio files to Checkboxs

public class CheckBoxesToAudioFiles {
     Map checkToAudio;

     public CheckBoxesToAudioFiles {
          checkToAudio = new HashMap();
     }
     
     public void mapCheckboxToAudioFile(JCheckbox cb, AudioFile af) {
          checkToAudio.put(cb, af);
     }
     
     public AudioFile getAudioFileForCheckbox(JCheckbox cb) {
          (AudioFile)return checkToAudio.get(cb);
     }
     
}


0
Comment
Question by:Drop_of_Rain
  • 3
  • 2
5 Comments
 

Author Comment

by:Drop_of_Rain
ID: 10692244
Let me clarify this better. The numbers that are generated through this code needs to go into an arraylist in the same order. I have to be able to have each number go to an audio file which are in a hashmap linked to a checkbox.


0
 
LVL 15

Accepted Solution

by:
Javatm earned 500 total points
ID: 10696654
Looks like your making a Java Media Player :)
0
 

Author Comment

by:Drop_of_Rain
ID: 10696659
No I'm making a training program. And cin use all the help I can get.
0
 
LVL 15

Expert Comment

by:Javatm
ID: 10697427
Can you tell me what you need to accomplish about your question above ?
0
 

Author Comment

by:Drop_of_Rain
ID: 10697476
If you could go to this question you will get an understanding of what I am trying to accomplish with the program.  

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20933110.html

What I need first is to be able to have the numbers that are generated from this code to be stored into a source (I'll leave that up to you) in the same order as they are generated. I then need those stored numbers to be linked to an audio file in a hashmap. (the code above)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is the latest versions eclipse neon 2 139
ArrayIndexOutOfBoundException 9 67
JList custom Cell Renderer refresh 15 53
xampp tool 12 25
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now