Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

linking code together

Posted on 2004-03-26
5
Medium Priority
?
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

609 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