Solved

linking code together

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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.

762 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

19 Experts available now in Live!

Get 1:1 Help Now