Help creating a array

Hi i've got a simple guessing game. Which the user has to guess the right number. A hint will be displayed if the users guess is cold, warm or hot. Each game has 8 rounds in which they have to guess 8 numbers, but each number they have 3 attempts to guess if they guess correct it will say you won and add one to games won and if they lose on there 3rd attempt it will show a message saying sorry and show the number. At the end of the 8 rounds it will give them a result depending on how many games were won.
I have managed to do all this so far, but the problem that i have is i need to make this game so it can be played by multiplayers. A message will ask how many players, max 6. The computer has to have one random number for each round. Each player plays 8 rounds, taking turns in guessing the number. Once 8 rounds are up the program should print a message saying which player won most games.
I'm not really sure how to go about doing this? I'm guessing i need an array to store each players wins and then an if statement or switch statement saying if player 1 > player 2 and for all of them then player one wins? But even this the array still confuses me not really sure how to go about it?
Any help is much appreciated, heres my code so far.
package assessment;
import javax.swing.JOptionPane;
public class guessingGame{
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          final String win = "You won";
          final String lose = "Try again";
                    final int MAX_GUESS = 3;
          final int RANGE = 10;
          int ROUNDS = 8;
          int players = 0;
          int computersNumber = 0;
          int usersGuess = 0;
          int winCount = 0;
          int i, j = 0;
          String userInput;
          String output;
          String playersString;
                    int [] myArray = new int [players];
                    playersString = JOptionPane.showInputDialog(null, "How many players are going to take part?", "Players",
                         JOptionPane.WARNING_MESSAGE);
          players = Integer.parseInt(playersString);
          for(j = 0; j < ROUNDS; j++){
               // generate a random number between 1 and 10
               computersNumber = (int) (Math.random() * RANGE) + 1;
               System.out.println(computersNumber);
          for(i = 0; i < MAX_GUESS; i++) {
               userInput = JOptionPane.showInputDialog(null, "I am thinking of a number between 1 and 10 " +
                         "\n You have 3 attempt to guess what it is:",
                         "Guessing game", JOptionPane.INFORMATION_MESSAGE);
               usersGuess = Integer.parseInt(userInput);
                              boolean answer = checkAnswer(computersNumber, usersGuess);
                giveHint(computersNumber, usersGuess);
               if(answer == true) {
                    JOptionPane.showMessageDialog(null, win, "Result",
                              JOptionPane.WARNING_MESSAGE);
                    winCount++;
                    System.out.println("Wins" + winCount);
                    break;
               else if(answer == false) {
                    JOptionPane.showMessageDialog(null, lose, "Result",
                              JOptionPane.ERROR_MESSAGE);
                    System.out.println(j);
               if(i == 2){
                    JOptionPane.showMessageDialog(null, "Winning number was " + computersNumber,
                    "Guessing game", JOptionPane.INFORMATION_MESSAGE);
          JOptionPane.showMessageDialog(null, "Sorry you didn't win this time",
                    "Guessing game", JOptionPane.INFORMATION_MESSAGE);
          switch(winCount){
          case 1:
               output = "Amateur";
               break;
          case 2:
               output = "Amateur";
               break;
          case 3:
               output = "Amateur";
               break;
          case 4:
               output = "Amateur";
               break;
          case 5:
               output = "Amateur";
               break;
          case 6:
               output = "Advanced";
               break;
          case 7:
               output = "Professional";
               break;
          case 8:
               output = "Champion";
               break;
          default:
               output = "Need more practice";
               break;
          }// end switch statement
          // print message
          JOptionPane.showMessageDialog(null, output, "Check your grade",
                         JOptionPane.WARNING_MESSAGE);     
     public static boolean checkAnswer(int computersNumber, int usersGuess) {
          if(computersNumber == usersGuess) {
               return true;
          } else {
               return false;
          public static void giveHint(int computersNumber, int usersGuess) {
          if(usersGuess + 3 == computersNumber || usersGuess - 3 == computersNumber) {
               JOptionPane.showMessageDialog(null, "Hint - your guess was cold",
                         "Guessing game", JOptionPane.INFORMATION_MESSAGE);
          } else if(usersGuess + 2 == computersNumber || usersGuess - 2 == computersNumber) {
               JOptionPane.showMessageDialog(null, "Hint - your guess was warm",
                         "Guessing game", JOptionPane.INFORMATION_MESSAGE);
          } else if(usersGuess + 1 == computersNumber || usersGuess - 1 == computersNumber) {
               JOptionPane.showMessageDialog(null, "Hint - your guess was hot",
                         "Guessing game", JOptionPane.INFORMATION_MESSAGE);
}

Since Java is an object oriented language you might want to create a Player class. Then think about how you can break things down and decide where certain methods go, in the Player class or the game class.
As for determing the Player with the greatest wins, create another temp variable to hold the player with the most correct so far. Then you loop over all players and compare their wins with the temp variable. If it is greater swap them. a shortcut would be allocate player #1 to the temp variable then you only have to compare from player #2 onwards.

Similar Messages

  • Help creating an array

    I'm new to Life Cycle Designer and need help with the following script:
    txtComments.rawValue = Page1.Com1.rawValue + "\n" + Page1.Com2.rawValue + "\n" + Page1.Com3.rawValue;
    What I'd really like to do is create an array/function that concatenates the fields titled Com* if there is data in these fields on page 1 of my form and display the data in the txtComments field on page 3 of my form. If there is no data, I do not want "null" to display for that field. The final form may have 60+ Com fields... It would be awful to have to hand code each of these. All this is triggered by a specific radio button selection.
    I hope someone can help me. Let me know if you have questions. Thanks!

    It works, Paul!!!! Thank you, thank you, thank you!!! I augmented the code slightly to include a break in between the fields. This is what I ended up with:
    this.rawValue = " "
    for (i=1;i<=72;i++) {
         if (xfa.resolveNode("Page1.Com" + i).rawValue != null ){
              this.rawValue += xfa.resolveNode("Page1.Com" + i).rawValue + "\n";
    Now... the dilemna I have worked around for the time being is this... what if my Com fields flow over into pages 2 and 3? I suppose I could make additional txtComments fields, but that would look odd if nothing is populated on the 1st one and only a couple are say on the 2nd or 3rd page. Does that make sense? I lengthened my paper size in Word to get everything on one page as a work around, but I probably need to remedy this at some point considering I have a number of these forms to create. I played with the code a little bit to try and solve this on my own, but to no avail... yet. Thanks again!

  • Help creating 2D array from tab delimited text file

    I can print the info from the file, but darned if I can't make a 2-D array.
    import java.util.regex.*;
    import java.io.*;
    public final class goodSplitter {
        private static BufferedReader br;
        private static BufferedReader br2;
        private static String INPUT;
        private static int numLines;
        private static int numLine2;
        private static int q;
        private static int t;
        private static int n;
        private static String [][] indexArray;
        public static void main(String[] argv) {
            initResources();
            processTest();
            closeResources();
        private static void initResources() {
           try {
                  br = new BufferedReader(new FileReader("index.txt"));
              System.out.println("found the input file.");
                } catch (FileNotFoundException fnfe)
                   System.out.println("Cannot locate input file! "+fnfe.getMessage());
                          System.exit(0);
           try {
                  br2 = new BufferedReader(new FileReader("index.txt"));
              System.out.println("found file again.");
                } catch (FileNotFoundException fnfe)
                   System.out.println("Cannot locate input file again! "+fnfe.getMessage());
                          System.exit(0);
         try {     
                   int numLines = 0;     
                   while ( ( INPUT = br.readLine( ) ) != null )
                        { numLines++; } // end while
                   System.out.println("file has the number of lines: " + numLines);
                   q = numLines;
                   System.out.println("creating the array.");
                   String [][] indexArray = new String[q][];
                   System.out.println("populating the array.");
                   while ( ( INPUT = br2.readLine( ) ) != null ) {
                        n = t++;
                        System.out.println("first array index = " + n);
                        String[] ss = INPUT.split("\\s");
                        for(int i = 0; i < ss.length; i ++)
                                  System.out.println( new String( ss[i] ) );
                                  indexArray[n] = ss[i];
                             } // end for
                        } // end while
         } catch (Exception e)
              {System.out.println("something went wrong in populating the array of length " + q); }}
    private static void processTest() { System.out.println("processed text."); }
    private static void closeResources() {
    try{ br.close();  }catch(IOException ioe){} }

    you haven't sized the 2nd part of the 2d array
    add this line
    String[] ss = INPUT.split("\\s");
    indexArray[n] = new String[ss.length];//<--------------
    for(int i = 0; i < ss.length; i ++)
    but note you have declared indexArray both as a class variable
    private static String [][] indexArray;
    and a variable local to the try/catch block
    String [][] indexArray = new String[q][];
    probably what you want is
    indexArray = new String[q][];

  • Help creating an array from a list of vector item

    I am writing a Email Handling class that uses an Email class that I have already written. The spec requires me to (A.) Create a DisplayEmail(Email[] e) method that takes and array of email messages and displays them in the terminal window. And then (B) to create some retrieval methods ie: Email [] RetrieveSubject(String searchValue) which "will allow me to retrieve objects from the data structure created in (A.)and sorts them.
    I wonder if you could give my some advice on how to implement this? I have used a Vector to store the emails. Here is what I have so far. . From what I understand I am suppose to create array methods for all of these tasks. Don't know where to begin, can u help please. I've created a vector to store the emails, but I am not sure about the array method bit. As you can see all of my methods are standard and I think they need to be arrays. Please Help
    import java.util.*;
    public class EmailHandler{
    private Vector emails;
    public EmailHandler(){
         emails = new Vector();
    public EmailHandler(int size){
         emails= new Vector(size);
    public void addEmail(Email e){
         emails.addElement(e);
    public void displayEmail(Email de)
    public void displayArrayOfEmails(Email[] ea)
    public Email RetrieveSender(String searchSender)
         Email thisEmail;
         //look through vector for search element
         if(emails.size()>0){
              for (int i=0;i<emails.size();i++){
                   //take emails in turn search for subject
                   thisEmail = (Email) emails.elementAt(i);
                   //check subject against search value input
                   if(thisEmail.getSender().equalsIgnoreCase(searchSender))          {
                        return thisEmail;
         }     //if you find yourself here, no subject is found
              return null;
    public Email RetrieveRecipient(String searchRecipient)
         Email thisEmail;
         //look through vector for search element
         if(emails.size()>0){
              for (int i=0;i<emails.size();i++){
                   //take emails in turn search for subject
                   thisEmail = (Email) emails.elementAt(i);
                   //check subject against search value input
                   if(thisEmail.getRecipientName().equalsIgnoreCase(searchRecipient))          {
                        return thisEmail;
         }     //if you find yourself here, no subject is found
              return null;
    public Email RetrieveSubject(String searchSubject)
         Email thisEmail;
         //look through vector for search element
         if(emails.size()>0){
              for (int i=0;i<emails.size();i++){
                   //take emails in turn search for subject
                   thisEmail = (Email) emails.elementAt(i);
                   //check subject against search value input
                   if(thisEmail.getSubject().equalsIgnoreCase(searchSubject))          {
                        return thisEmail;
         }     //if you find yourself here, no subject is found
              return null;

    i've anwered your question in your crosspost over here:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=472997&tstart=0&trange=30

  • Need Help Creating Image Array

    Hello,
    I am a newbie at Flex 2 and I am working on this site that
    needs an image array consisting of 5 images. The ideal thought
    would be for the images to load into an HBox I created as a holding
    place and have the images change every 5 seconds or so. I have
    looked around the forums and the internet but I have yet to find
    anything. If anyone can please help me on this I would greatly
    appreciate it.
    Regards,
    Jose

    If you've done what I think you have, then I may have tried something similar.
    I tried creating a BufferedImage in a JPanel, basing the size of the BufferedImage on the size of the JPanel in the constructor, but when the JPanel was created, it tried to set up the image before resizing the JPanel i.e. the BufferedImage size was set to (0,0) and that threw an IllegalArgumentException at runtime. I found that I had to declare variables for an initial image size, then optionally change the image size later.
    Hope that helps.

  • Help with method/array lab

    I need some help creating an array of students in my lab, using a method. I'm fairly confused on how to do this. This is a sample of my code, i've deleted a lot of the stuff further down thats not needed atm.
    Anyhow, I understand how arrays work and whatnot, but have no clue as to how to create the array in the method. Any help please! (The last few lines of posted code is where the array should go)
    import java.util.Scanner;
    import java.io.*;
    public class Lab6
        public static void main(String[] args)
            // Fill in the body according to the following comments
             Scanner keyboard = new Scanner(System.in);
             // Input file name
         String fileName = getFileName(keyboard);
             // Input number of students
         int numberOfStudents = FileIOHelper.getNumberOfStudents(fileName);
             // Input all student records and create Student array and
         Student [] studentAry = new Student [numberOfStudents];
             // integer array for total scores
        // Given a Scanner in, this method prompts the user to enter
        // a file name, inputs it, and returns it.
        private static String getFileName(Scanner keyboard)
             String fileName;
         System.out.print("Enter input file name: ");
        fileName = keyboard.nextLine();
        return fileName;
        // Given the number of students records n to input, this
        // method creates an array of Student of the appropriate size,
        // reads n student records using the FileIOHelper, and stores
        // them in the array, and finally returns the Student array.
        private static Student[] getStudents(int n)
            // Fill in the body
        }

    Oh btw, this is sample code givin to me by my professor that may help?
            // Copy a student from the file to the array
              Student aStudent = FileIOHelper.getNextStudent();
              studentAry[0] = aStudent;
              // Copy another student to the array
              aStudent = FileIOHelper.getNextStudent();
              studentAry[1] = aStudent;
              // Get student information from the array
              String name = studentAry[1].getName();
              int s1 = studentAry[1].getScore(1);
              int s2 = studentAry[1].getScore(2);
              int s3 = studentAry[1].getScore(3);

  • Help creating an external array for a scoreboard

    I'm trying to create an array in an external file that will recieve and arrange scores sent from Quiz.fla upon clicking the submit score button.  I also want another fla file to be able to reference this external array and pull the top 15 scores from it, and then display those scores on a scrolling banner.  I want the banner to be able to update dynamically (I assume reloading the banner fla each time it reaches the end of its cycle, having the first frame load the external array on an onClipEvent action would accomplish this), that way it will update while remaining open.  The main reason I need two separate files for the quiz and the score banner is they will be displayed on two different monitors.  What would be the most efficient way of accomplishing this?  I know a little about actionscript but I don't have much experience with calling data and functions from external fla or as files (the array and the function designating how the data will be arranged within said array are going to be in a separate .as file).
    I'm currently working in AS2, since I've had almost no experience with AS3.

    So if I wanted to avoid using a server, I'd basically have to set up the
    array storing the high scores in an external .as or .swf file which would
    then be called into the quiz game to store the scores, and then called by
    the banner each time it hits frame 1 to refresh the numbers?  But then that
    would run into the problem of a shared object being used by two different
    clients I guess?  Servers setup and accessing confuses the hell out of me
    right now, so I'm trying not to make things to hellish for myself...
    Would there be a way to create 2 external database files within the folder
    holding the .swf files to somehow get around the issue of one sharedobject
    being accessed by two clients?

  • Need help creating custom objects and adding them to an array.

    Hi Everyone,
    So I'm dinking around in Powershell today and I'm failing at creating an array of custom objects.  I want to create a HTML report that builds out after every MDT image update. To do that, I need to collect my data on what's contained in each build.
    Here's my current script in progress -
    function Parse-Dependents($fullname){
    #PARAMETER SWITCHING
    if(!($fullname)){
    $dependents = get-dependents
    if($fullname){
    $dependents = get-dependents -fullname $fullname
    #SPIN THROUGH ARRAY OF GUIDS FROM GET-DEPENDENTS
    foreach($d in $dependents){
    #SPIN THROUGH EACH APP IN APPLICATIONS.XML
    foreach ($app in $apps){
    #IF MATCH THEN ADD OBJECT WITH PROPERTIES
    if($d -match $app.guid){
    #ADD APPLICATION MATCH TO THE ARRAY
    $applications = @{
    'Name' = $app.ShortName;
    'GUID' = $app.Guid;
    'Version' = $app.Version;
    'Last Modified Time' = $app.LastModifiedTime;
    'Last Modified By' = $app.LastModifiedBy;
    'Install Directory' = [string]'\\my\path\to\MDT\' + $app.WorkingDirectory.TrimStart(".","\")
    'CommandLine' = $app.CommandLine;
    new-object -typename PSObject -property $applications
    #RETURN MATCHED ARRAY
    return $applications
    It all works great until I look at my output and see that I get my expected properties and array, but at the end it's created additional empty entries for each of my initial properties I assigned.  So I get my list of apps like this :
    powershell.ex... OrgChart Plugin  \\my\mdt\server\ XX\user                     9/22/2014 5:... {ffee7497-0c...
    And then below it :
                     CommandLine                                                                                    
                     Name                                                                                           
                     Install Direc...                                                                               
                     Last Modified By                                                                               
                     Version                                                                                        
                     Last Modified...                                                                               
                     GUID                                                                                           
    And these are all listed under the Name property.  I'm still pretty new to PS (8 months or so now), and rarely have to create a custom object, but this seems like a case for doing so to create a custom html report.  Any ideas would be greatly appreciated.
    Ryan

    It's not really all that strange.  
    If you look at your script, you're not outputting the hash table until both loops finish.  The values are dependent on the properties of the $app objects enumerated in the inner loop, and only outputting an object if the dependent ($d) matches the $app
    guid property.
    At the end, you're outputting the hash table without that test, so it's going to have values based on the last $app in the loop, regardless of whether the guid matches the dependents or not.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Can someone help me in creating an Array for the following?

    Hi this is a flash banner done using AS3 but it is giving me bugs when published, can someone please look at the the following link http://webtemp2.idm.net.lb/alamflash/home.html 
    and below is the script, can i create an array?
    stop();
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    mc_animation.mc_scaffold.buttonMode = true;
    mc_animation.mc_prop.buttonMode = true;
    mc_animation.mc_ladder.buttonMode = true;
    mc_animation.mc_tower.buttonMode = true;
    mc_animation.mc_trade.buttonMode = true;
    ///////////////////// start ///////////////////////////////
    new Tween (mc_animation.mc_scaffold,"y", Elastic.easeInOut,-300,3,1.5,true);
    new Tween (mc_animation.mc_prop,"y", Elastic.easeInOut,-300,3,2,true);
    new Tween (mc_animation.mc_ladder,"y", Elastic.easeInOut,-300,3,2.5,true);
    new Tween (mc_animation.mc_tower,"y", Elastic.easeInOut,-300,3,3,true);
    new Tween (mc_animation.mc_trade,"y", Elastic.easeInOut,-300,3,3.5,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,-300,15,1,true);
    /////////////////////// scaffolding ////////////////////////////
    function scafoldinfo(e:Event):void {
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,1000,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,1100,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,1200,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,1300,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,1400,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,-300,1.5,true);
    new Tween (im_scaffolding,"x", Elastic.easeInOut,-1100,0,5,true);
    new Tween (info_scaffold,"y", Elastic.easeInOut,-300,30,6,true);
    function closescafoldinfo(e:Event):void {
    new Tween (info_scaffold,"y", Elastic.easeOut,30,300,5,true);
    new Tween (im_scaffolding,"x", Elastic.easeInOut,0,-1100,2,true);
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,2.4,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,197.3,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,392.3,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,587.5,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,782.2,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,30,2,true);
    mc_animation.mc_scaffold.addEventListener(MouseEvent.CLICK,scafoldinfo);
    info_scaffold.btn_close.addEventListener(MouseEvent.CLICK,closescafoldinfo);
    ///////////////////////////////////////////////// propping///////////////////////////////////////////////////////////
    function proppinginfo(e:Event):void {
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,1000,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,1100,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,1200,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,1300,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,1400,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,-300,1.5,true);
    new Tween (im_propping,"x", Elastic.easeInOut,-1100,0,5,true);
    new Tween (info_proping,"y", Elastic.easeInOut,-300,30,6,true);
    function closeproppinginfo(e:Event):void {
    new Tween (info_proping,"y", Elastic.easeOut,30,300,5,true);
    new Tween (im_propping,"x", Elastic.easeInOut,0,-1100,2,true);
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,2.4,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,197.3,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,392.3,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,587.5,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,782.2,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,30,2,true);
    mc_animation.mc_prop.addEventListener(MouseEvent.CLICK,proppinginfo);
    info_proping.btn_close.addEventListener(MouseEvent.CLICK,closeproppinginfo);
    //////////////////////////////////// Ladders //////////////////////////////////////////////////////
    function laddersinfo(e:Event):void {
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,1000,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,1100,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,1200,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,1300,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,1400,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,-300,1.5,true);
    new Tween (im_ladders,"x", Elastic.easeInOut,-1100,0,5,true);
    new Tween (info_ladders,"y", Elastic.easeInOut,-300,30,6,true);
    function closeladdersinfo(e:Event):void {
    new Tween (info_ladders,"y", Elastic.easeOut,30,300,5,true);
    new Tween (im_ladders,"x", Elastic.easeInOut,0,-1100,2,true);
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,2.4,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,197.3,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,392.3,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,587.5,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,782.2,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,30,2,true);
    mc_animation.mc_ladder.addEventListener(MouseEvent.CLICK,laddersinfo);
    info_ladders.btn_close.addEventListener(MouseEvent.CLICK,closeladdersinfo);
    //////////////////////////////////// towers //////////////////////////////////////////////////////
    function towersinfo(e:Event):void {
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,1000,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,1100,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,1200,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,1300,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,1400,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,-300,1.5,true);
    new Tween (im_towers,"x", Elastic.easeInOut,-1100,0,5,true);
    new Tween (info_tower,"y", Elastic.easeInOut,-300,30,6,true);
    function closetowersinfo(e:Event):void {
    new Tween (info_tower,"y", Elastic.easeOut,30,300,5,true);
    new Tween (im_towers,"x", Elastic.easeInOut,0,-1100,2,true);
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,2.4,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,197.3,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,392.3,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,587.5,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,782.2,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,30,2,true);
    mc_animation.mc_tower.addEventListener(MouseEvent.CLICK,towersinfo);
    info_tower.btn_close.addEventListener(MouseEvent.CLICK,closetowersinfo);
    //////////////////////////////////// trading //////////////////////////////////////////////////////
    function tradinginfo(e:Event):void {
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,1000,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,1100,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,1200,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,1300,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,1400,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,-300,1.5,true);
    new Tween (im_trading,"x", Elastic.easeInOut,-1100,0,5,true);
    new Tween (info_trading,"y", Elastic.easeInOut,-300,30,6,true);
    function closetradinginfo(e:Event):void {
    new Tween (info_trading,"y", Elastic.easeOut,30,300,5,true);
    new Tween (im_trading,"x", Elastic.easeInOut,0,-1100,2,true);
    new Tween (mc_animation.mc_scaffold,"x", Elastic.easeInOut,mc_animation.mc_scaffold.x,2.4,4,true);
    new Tween (mc_animation.mc_prop,"x", Elastic.easeInOut,mc_animation.mc_prop.x,197.3,3.5,true);
    new Tween (mc_animation.mc_ladder,"x", Elastic.easeInOut,mc_animation.mc_ladder.x,392.3,3,true);
    new Tween (mc_animation.mc_tower,"x", Elastic.easeInOut,mc_animation.mc_tower.x,587.5,2.5,true);
    new Tween (mc_animation.mc_trade,"x", Elastic.easeInOut,mc_animation.mc_trade.x,782.2,2,true);
    new Tween (mc_animation.mc_separators,"y", Elastic.easeInOut,mc_animation.mc_separators.y,30,2,true);
    mc_animation.mc_trade.addEventListener(MouseEvent.CLICK,tradinginfo);
    info_trading.btn_close.addEventListener(MouseEvent.CLICK,closetradinginfo);

    I am afraid this is undocumented usage of Tween class. According to the class documentation one needs to create instances of Tween. Since there are no explicit instances - I suspect that one Teen is overriding another or, perhaps, is not getting instantiated all together.
    So, the documented usage is:
    var tween:Tween = new Tween()
    Not just new Tween()
    Re: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/transitions/Tween.html
    I also would suggest you look into TweenLite or TweenMax classes - they are much more compact, easier to use and accommodate several properties tweening in one swoop.

  • Main.vi creates 2D Arrays and I want to save the arrays in an microsoft Excel file(e.g engine_1)and in differnt worksheets(e.g. measure_1;measure_2;...)

    main.vi creates 2D Arrays and I want to save the arrays in an microsoft Excel file(e.g engine_1)and in differnt worksheets(e.g. measure_1;measure_2;...)
    The path(Grundpfad)for the excel file should be inserted in the main.vi.

    1. There's a shipping example called Write Table To XL.vi (Help>Find Examples>Communicating with External Applications>ActiveX>Excel) that you can use as a starting point.
    2. Buy the LabVIEW Report Generation Toolkit. Info can be found here.
    3. Search this forum for other examples of writing to Excel.

  • How to create an array with Generic type?

    Hi,
    I need to create a typed array T[] from an object array Object[]. This is due to legacy code integration with older collections.
    The method signature is simple:public static <T> T[] toTypedArray(Object[] objects)I tried using multiple implementations and go over them in the debugger. None of them create a typed collection as far as I can tell. The type is always Object[].
    A simple implementation is just to cast the array and return, however this is not so safe.
    What is interesting is that if I create ArrayList<String>, the debugger shows the type of the array in the list as String[].
    If I create ArrayList<T>, the class contains Object[] and not T[].
    I also triedT[] array = (T[]) Array.newInstance(T[].class.getComponentType(), objects.length);And a few other combinations. All work at runtime, create multiple compilation warnings, and none actually creates T[] array at runtime.
    Maybe I am missing something, but Array.newInstace(...) is supposed to create a typed array, and I cannot see any clean way to pass Class<T> into it.T[].class.getComponentType()Returns something based on object and not on T, and T.class is not possible.
    So is there anything really wrong here, or should I simply cast the array and live with the warnings?
    Any help appreciated!

    Ok. May be you could keep information about generic type in the your class:
    public class Util {
        public static <T> T[] toTypedArray(Class<T> cls, Object[] objects){
            int size = objects.length;
            T[] t = (T[]) java.lang.reflect.Array.newInstance(cls, size);
            System.arraycopy(objects, 0, t, 0, size);
            return t;
    public class Sample<T> {
        Class<T> cls;
        T[] array;
        public Sample(Class<T> cls) {
            this.cls = cls;
        public void setArray(Object[] objects){
            array = Util.toTypedArray(cls, objects);
        public T[] getArray(){
            return array;
        public static void main(String[] args) {
            Object[] objects = new Object[] { new LinkedList(), new ArrayList()};
            Sample<List> myClass = new  Sample<List>(List.class);
            myClass.setArray(objects);
            for(List elem: myClass.getArray()){
                System.out.println(elem.getClass().getName());
    }

  • How to create an array in bpel?

    I am trying to integrate a web service into open-esb. The web service consumes an unbounded array of a "userInfo" data structure. The issue is that although I can create bpel to receive a message like this, due to type incompatibilities I need to create a different array within bpel to pass to the webservice.
    To date I have not found a way to create an array within open-esb's bpel. After extensive googling I have found that other ESBs define their own proprietary extensions to add nodes to an array.
    Thus I have two questions:
    First, does open-esb support creation of arrays? and if so, how do I create the array and add nodes to it?
    Second, and perhaps more importantly, is using an <assign> activity the best way to transfer a potentially large array from one variable to another (i.e., will it perform well)? Or should I use XSLT to transform the array from one wsdl type to another? And if XSLT is the answer, how can I do this within open-esb?
    Thanks in advance,
    Steve
    PS. Based on the various googlings Ive been doing this question seems to be frequently asked. If someone will help me find a solution I plan on writing a short "how-to" article for posting back to the community. Given that arrays are one of the most basic data structures I hope the article will be useful for others struggling with this issue.

    I think this is all covered in Steve-Nies other thread concerning this subject, entitled "Need help with BPEL please" (http://forum.java.sun.com/thread.jspa?threadID=5116270&tstart=0)

  • How do I create an Array of Images

    Hi,
    I'm creating a program that basically is a slideshow. It has buttons that allow the user to switch from image to image, and has some audio in the background. I was wondering how I might create an array to store the images. I'm very new to Java, so please no detail is too small. I've just started using arrays, so I'm not sure where I would store the files or how to call the images. Please be descriptive and as dumbed down as possible :)
    Thanks for the help!

    I like ArrayList
    ArrayList<BufferedImage> myPics = new ArrayList();then just dump them in with add(myBufferedImage)
    If you'e not using BufferedImages then just change the BufferedImage to Image.
    to get, say the 6th image back out, then use:
    myBufferedImage = myPics.get(5);the index starts at 0 and should be addressed as 0 to (myPics.length - 1)

  • How to create Componet array in NetBean?

    I want to create ten or more text field with same format.
    Also want to use NetBean to done it with out typing the code self.
    How can I do?
    I mean whether easy and fast method to create componet array in netbean.

    I want to create ten or more text field with same
    format.
    Also want to use NetBean to done it with out typing
    the code self.Why not? because it's the fastest, simplest and safest way.
    How can I do?
    I mean whether easy and fast method to create
    componet array in netbean.Just like oyu'd do it without Netbeans.
    If you still want to do it in Netbeans, I suggest reading the manual. This is not a Netbeans product support forum, and I'm definitely not inclined to help as you don't want it done by writing code yourself.

  • How to create an array of indefined elements

    Hi. I need to write a program that store n number of elements in an array. The program have to ask the user to input some values, and it stops until the user says that he dont want to input more values.
    I have the following code:
    public class Controlador{
      private Contacto[] lista;
      private int contactoActual;
      private int continuar = 0;
      private Interfaz interfaz = new Interfaz();
      public Controlador(){
        lista = new Contacto[contactoActual];
        contactoActual++;
      public void insertarContacto(){
        do{
          Contacto persona = new Contacto();
          persona.insertarNombre();
          persona.getNombre();
          persona.getTelefono();
          contactoActual++;
          lista[contactoActual] = persona;
          continuar = interfaz.mostrarContinuar();
        }while(continuar==1);
      }with this, I got an array out of bounds exception.
    Can somebody help?
    regards.

    Yes and no.
    Once you have created an array you cannot change its size. So if you create an array of size 10 and user wants to input 11 numbers, your progrm will crash. Hoever you can get around this by checking the size of the array before inserting. If the array is full, create another array that is bigger, copy all values from original array to new array and then insert the new number. All this requires a lot of work. Use a Collection such as an ArrayList so you don't have to worry about the size.

Maybe you are looking for

  • How do i share files using airdrop betwenn apple devices?

    How do i share files between apple devices iPhone, iPad or mac using airdrop. I selected a file in my iPhone and turned on AirDrop in my mac and my ipad. but no device listed. Guide me how do i share. Thanks Abdul

  • I have lost Acrobat 9 off my computer. Help?

    I use a Mac and had to reinstall the design premium suite of products because of an initial problem with an Authentication code for my Acrobat 9. It asked me to open up Photoshop and I did. Nothing happened and after reading all forums I decided to r

  • SOAP adapter installation and activation

    We have installed XI 3.0 SR1 and wish to enable the sender SOAP adapter to receive SOAP messages from a different (PeopleSoft) system.  The documentation we have found really seems to be lacking in the area on installing and activating the SOAP adapt

  • How to handle multiple connection through JCO

    Hello JCo Experts, My requirement is as follows: > I need to create a Web Dynpro Java Application > I have multiple users (different Users on SAP System). > I need to execute BAPI/Module Functions through these multiple users. Example: Users: A and B

  • OWB 9.2 locaiton registration error

    I'm new to OWB. Here is what I'm trying to do: 1. Set up runtime platform, create design reporsitory andcreate a project. 2. Create module with location Loc1 defined. 3. Create Runtime Repository Connection Rtrc1 4. Start deployment manager to regist