Solved

linking code together

Posted on 2004-03-26
5
218 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

832 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