Solved

Help with a If statement

Posted on 2004-04-25
15
231 Views
Last Modified: 2010-03-31
I need to have a If statement that does some comparisons. I will have some names of ojbects dm1-dm50. There will be a tining cycle being used in the workout. But if certain dm's are in the workout there will need to be a different timing cycle used. So I need a If statement to check throught the process to replace the timing cycle.  This will happen when the 2 lists used with the wrapper will be making one list to make the single audiofile out of the many. Below is the listener fot the buttons and details classes below.


public class MyListener implements ActionListener {

    private List theList = new ArrayList();

    public MyListener() {
    }

    public void addButton(JButton theButtonToAdd) {
       theButtonToAdd.addActionListener(this);  // Listen for the button to be pressed
    }

    public void actionPerformed(ActionEvent e) {
       JButton button = (JButton)e.getSource();
       String command = button.getActionCommand();
       AudioDetails details = new AudioDetails(command, timing);
       if (thList.contains(details))
       {
          theList.remove(details);
       }
       else
       {
          theList.add(details);
       }
    }




    public List getList() { return theList; }

}


public class AudioDetails
{
   private String AudioFile;
   private String Timing;
   // could add other fields as needed

   public AudioDetails(String file, String timing)
   {
      AudioFile = file;
      Timing = timing;
   }

   public String getAudioFile()
   {
      return AudioFile;
   }

   public String getTiming()
   {
      return Timing;
   }
}
0
Comment
Question by:Drop_of_Rain
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10914636
so what is the logic you need to achieve exactly?
0
 

Author Comment

by:Drop_of_Rain
ID: 10914685
I can change the details in the statements later

 If  (dm6, dm8, dm21, dm22, dm26)  are being used, then 2 seconds more then the timing cycle being used needs to be used instead.

If (dm9, dm11, dm28, dm31, dm35)  are being used, then 3 seconds more then the timing cycle being used needs to be used instead.

Otherwise the regular timing cycle
0
 
LVL 3

Expert Comment

by:fave_17
ID: 10914743
What is the flag that will indicate a dm1...dm50 object is used?
0
 

Author Comment

by:Drop_of_Rain
ID: 10914776
Ok I need to go into more detail here. There will be many different ActionCommands coming from many different buttons all going into the MyListener class and then AudioDetails class making up the final list. That list will then become starems and go into the class that makes the single audio file out of that list.
0
 
LVL 2

Expert Comment

by:d_tan
ID: 10915114
I am not really clear on the logic behind your program. . .

but for the if statement, how about using a bit vector and using bitwise and's and or's to see which dms are on/off?

dtan
0
 

Author Comment

by:Drop_of_Rain
ID: 10915196
<I am not really clear on the logic behind your program. . .>

I wrote this to objects because he was the one helping me with the question and has been helping me with my program a lot already.

Ok I will explain it a little better for you.

The program will create a single audiofile out of many small audiofiles. There are many buttons that have there ActionCommands set as audiofiles. The user will be able to create any custom workout they want by choosing what they want in the workout by presseing those buttons. There will be a timing cycle automaticly placed between each option. The user can see what they have selected and remove anyone they want removed. This is handled by MyListener it removes the timing cylcle as well. Details create one list out of two in a way. This If statement will be used in other places as well, I will just make slight changes to it.

This needs to happen when the list is being created.
0
 
LVL 92

Expert Comment

by:objects
ID: 10915285
do you actually need to maintain this information while the user is selecting the buttons, or could you instead determine the relevant timings at the point when you assemble the single audio.
0
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.

 

Author Comment

by:Drop_of_Rain
ID: 10915302
Yes it wouldn't matter when it happens really.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10915381
Any how for every action, you will attach an AudioDetails.  That itself will have the timings.  Then what exactly are  you looking for.


Regards,
Muruga
0
 

Author Comment

by:Drop_of_Rain
ID: 10915398
<Then what exactly are  you looking for>


There will be a tining cycle being used in the workout. But if certain dm's are in the workout there will need to be a different timing cycle used because it takes longer to do.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 10915412
> Yes it wouldn't matter when it happens really.

then theres no need to worry about it in the code you have posted above.
Deal with it in the code that assembles the final audio.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10915420
That is what I am about to ask... post your code which assembles the final audio
0
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 300 total points
ID: 10937032
0
 

Author Comment

by:Drop_of_Rain
ID: 10937077
Thanks for all the support,
Christopher
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10937080
that's great... thanx.. :-)
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
groupNoAdj 7 84
Java Message handling in Service Layer 3 55
maven example error 3 52
servlet  URL Rewriting 1 25
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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

932 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

13 Experts available now in Live!

Get 1:1 Help Now