Another set of eyes

I could use a second look. Why is name outputting null rather than "no name yet?"
import java.util.Scanner;
public class Exercise5
    public static void main(String[] args)
       //Create the contructors
        Species species1 = new Species();
        Species species2 = new Species();
        Species species3 = new Species();
        //Output the initial values of the three constructors
        System.out.println("==================== Initial Values ====================");
        System.out.println("\nSpecies 1");
        species1.writeOutput( );
        System.out.println("\nSpecies 2");
        species2.writeOutput( );
        System.out.println("\nSpecies 3");
        species3.writeOutput( );
import java.util.Scanner;
Class for data on endangered species.
public class Species
    private String name;
    private int population;
    private double growthRate;
    public void readInput( )
        Scanner keyboard = new Scanner(System.in);
        System.out.println("What is the species' name?");
        name = keyboard.nextLine( );
        System.out.println(
                      "What is the population of the species?");
        population = keyboard.nextInt( );
        while (population < 0)
            System.out.println("Population cannot be negative.");
            System.out.println("Reenter population:");
            population = keyboard.nextInt( );
        System.out.println("Enter growth rate (% increase per year):");
       growthRate = keyboard.nextDouble( );
    public void writeOutput( )
         System.out.println("Name: = " + name);
         System.out.println("Population: = " + population);
         System.out.println("Growth rate: = " + growthRate + "%");
     Precondition: years is a nonnegative number.
     Returns the projected population of the calling object
     after the specified number of years.
    public int predictPopulation(int years)
          int result = 0;
        double populationAmount = population;
        int count = years;
        while ((count > 0) && (populationAmount > 0))
            populationAmount = (populationAmount +
                          (growthRate / 100) * populationAmount);
            count--;
        if (populationAmount > 0)
            result = (int)populationAmount;
        return result;
    public void setSpecies(String newName, int newPopulation,
                           double newGrowthRate)
        name = newName;
        if (newPopulation >= 0)
            population = newPopulation;
        else
            System.out.println("ERROR: using a negative population.");
            System.exit(0);
        growthRate = newGrowthRate;
    public String getName( )
        return name;
    public int getPopulation( )
        return population;
    public double getGrowthRate( )
        return growthRate;
    public boolean equals(Species otherObject)
        return (name.equalsIgnoreCase(otherObject.name)) &&
               (population == otherObject.population) &&
               (growthRate == otherObject.growthRate);
    //set the default species constructor
    public void Species ()
          String name = "No name yet";
          int population = 0;
          double growthRate = 0.0;
     //set a constructor using just the initialName
     public void Species(String initialName)
          String name = initialName;
          int population = 0;
          double growthRate = 0.0;
     //set a constructor using initialName and initialPopulation
     public void Species(String initialName, int initialPopulation, double initialGrowthRate)
          String name = initialName;
          int population = initialPopulation;
          double growthRate = initialGrowthRate;
}

warnerja wrote:
public void Species ()And don't forget the other hint: The above is NOT defining a constructor. It is defining a method named "Species", which you never invoke, so even if you just change the code as suggested so far, you'll still have a null.<GRUMBLE>
... and in my humble opinion both these "common problems" should result in compiler warning.
public void Species ()
                    ^
STYLE_WARNING: The 'public void Species()' method has the same name as the containing class, making it look like a
constructor. This method name is confusing to other programmers, and is a likely cause of future bugs. This is
most commonly a mistake. If you meant 'Species()' to be a constructor then remove the return type. If you
meant this to be a method then you should rename it.
    String name = "No name yet";
    ^
STYLE_WARNING: The local variable 'name' hides the class attribute of the same name (this.name). This is confusing,
especially to other programmers, and is a common cause of bugs. Consider renaming the local variable, or
the attribute.</GRUMBLE>

Similar Messages

  • Opening .txt file - Need another set of eyes

    Hi folks - The attached file opens in Notepad and MS Excel as 9999 rows x 3 columns (X,Y,Z values, respectively).  I have tried different delimiters using 'Read From Spreadsheet File.vi' to bring in all the data but only successful bringing in the first column of 9999 values.  Can someone take a look at this and give me the trickto get it open using LabVIEW?  I expect it is something very simple but it is a Monday, isn't it?
    Thanks in advance.
    Don
    Solved!
    Go to Solution.
    Attachments:
    XYZ.txt ‏292 KB

    If you've ever been burned by this before, please kudo altenbach's Idea Exchange submission...
    Indicate the display format of Strings
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Need another set of eyes...

    i'm trying to build a search string and either my tick/quote marks are messing me up or i'm building the LIKE statement wrong. if a user types 'JOHN' in item :P1_LASTNAME, i'd like for all records with 'JOHN' to be returned (ex. JOHN, JOHNSON, JOHNNY).
    Declare
    x varchar2(2000);
    Begin
    x := 'select LASTNAME, FIRSTNAME from EMPLOYEES where 1=1 ';
    if :P1_LASTNAME is not null then
    x := x || ' AND upper(LASTNAME) like "%" ' || upper(:P1_LASTNAME) || ' "%" ';
    end if;
    if :P1_FIRSTNAME is not null then
    x := x || ' AND upper(FIRSTNAME) like "%" ' || upper(:P1_FIRSTNAME) || ' "%" ';
    end if;
    x := x || 'order by LASTNAME';
    return x;
    End;

    The code you wrote will concatenate percent signs (%) enclosed in double quotes (") to each side of the search string:
    select LASTNAME, FIRSTNAME from EMPLOYEES where 1=1
    AND upper(LASTNAME) like "%"JOHN"%"
    You want your query to have percent signs on either side of the search string enclosed in single quotes ('):
    select LASTNAME, FIRSTNAME from EMPLOYEES where 1=1
    AND upper(LASTNAME) like '%JOHN%'
    To escape a single quote in PL/SQL use two single quotes ('') as opposed to a double quote ("). They look VERY similar.
    if :P1_LASTNAME is not null then
    x := x || ' AND upper(LASTNAME) like ''%' || upper(:P1_LASTNAME) || '%'''';
    end if;
    ...

  • I need another set of eyes

    Can someone help me spot the problem? My if statement seems to take the original values not the new values?
    class MixMatchWindow extends JInternalFrame implements ActionListener
         String[] InFile = {"dog", "cat", "mat", "door"};
         String[] defFile = {"define dog", "define cat", "define mat", "define door"};
         int length = InFile.length;
         double randomNum[] = new double[length];
         double temp = 0.0;     
         int count = 0;
         public MixMatchWindow()
              super("Mix and Match",false,true,false,false);
              setBackground(Color.blue);
              setVisible(true);
              setBounds(0,0,710,570);
              getContentPane().setLayout(null);
              for(int r = 0; r < length; r++)
                   randomNum[r]= 10+(Math.random());
                   JLabel In = new JLabel("in rand loop "+randomNum[r]);
                   getContentPane().add(In);
                   In.setBounds(0,0+(r*25),210,35);
              for(int b = 0;b < length; b++)
                   /*JLabel InArray = new JLabel(InFile);
                   getContentPane().add(InArray);
                   InArray.setBounds(100,50+(b*50),100,25);*/
              for(int l = 0; l < length; l++)
                   for(int i = 0; i < length; i++)
                        if(temp > randomNum)
                             temp = temp;
                        else
                             temp = randomNum[i];
    //just for testing, these are the values I need
                   JLabel In3 = new JLabel("value of temp "+temp);
                   getContentPane().add(In3);
                   In3.setBounds(450,400+(l*25),150,35);
                   for(int w = 0; w < length; w++)
                        if(temp == randomNum[w])
    //just for testing
                   JLabel In2 = new JLabel("count loop "+count);
                   getContentPane().add(In2);
                   In2.setBounds(0,150+(w*25),110,35);
    //just for testing,revert to old values
                   JLabel In4 = new JLabel("temp loop "+temp);
                   getContentPane().add(In4);
                   In4.setBounds(100,150+(w*25),110,35);
                             /*JLabel RandArray = new JLabel(defFile[count]);
                             getContentPane().add(RandArray);
                             RandArray.setBounds(300,50+(w*50),100,25);*/
    //just for testing
                   JLabel In = new JLabel("b def loop "+randomNum[w]);
                   getContentPane().add(In);
                   In.setBounds(0,300+(w*25),110,35);
                             randomNum[count] = 0;
                             count = 0;
                             temp = 0;
                             break;                         
                        count= count+1;
              repaint();
         public void actionPerformed(ActionEvent e)

    You have two if statements, and it's far from clear what you mean. Be more explicit, and use code tags:
    [code]
    Program here

  • Please All. Am so scared to say I someone stole my Ipad and till now I haven't set my eyes on that ipad. I know quite sure that as I updated to iOS 7.0.2, I turned on my find my ipad feature. Now I can't even sign in to iCloud from another device.

    Please All. Am so scared to say I someone stole my Ipad and till now I haven't set my eyes on that ipad. I know quite sure that as I updated to iOS 7.0.2, I turned on my find my ipad feature. Now I can't even sign in to iCloud from another device. How best can someone help me to locate this device. Thanks. Chukks78

    Apple (and no one else) can not assist (with serial number or iCloud) in finding a lost or stolen iPad.
    Report to police along with serial number. Change all your passwords.
    These links may be helpful.
    How to Track and Report Stolen iPad
    http://www.ipadastic.com/tutorials/how-to-track-and-report-stolen-ipad
    Reporting a lost or stolen Apple product
    http://support.apple.com/kb/ht2526
    What to do if your iOS device is lost or stolen
    http://support.apple.com/kb/HT5668
    iCloud: Locate your device on a map
    http://support.apple.com/kb/PH2698
    iCloud: Lost Mode - Lock and Trace
    http://support.apple.com/kb/PH2700
    iCloud: Remotely Erase your device
    http://support.apple.com/kb/PH2701
    Report Stolen iPad Tips and iPad Theft Prevention
    http://www.stolen-property.com/report-stolen-ipad.php
    How to recover a lost or stolen iPad
    http://ipadhelp.com/ipad-help/how-to-recover-a-lost-or-stolen-ipad/
    How to Find a Stolen iPad
    http://www.ehow.com/how_7586429_stolen-ipad.html
    What NOT to do if your iPhone or iPad is lost or stolen
    http://www.tomahaiku.com/what-not-to-do-if-your-iphone-or-ipad-lost-or-stolen/
    Apple Product Lost or Stolen
    http://sites.google.com/site/appleclubfhs/support/advice-and-articles/lost-or-st olen
    Oops! iForgot My New iPad On the Plane; Now What?
    http://online.wsj.com/article/SB10001424052702303459004577362194012634000.html
    If you don't know your lost/stolen iPad's serial number, use the instructions below. The S/N is also on the iPad's box.
    How to Find Your iPad Serial Number
    http://www.ipadastic.com/tutorials/how-to-find-your-ipad-serial-number
    iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number
    http://support.apple.com/kb/HT4061
     Cheers, Tom

  • I am running OS10.6.8 and have a mail box duplication. I use gmail and when I open my mail I have both the Apple Mail and another set of boxes for Gmail. Both get all mail and when I delete from one, it deletes from the other. How can I get rid of the dup

    I am running OS10.6.8 and have a mail box duplication. I use gmail and when I open my mail I have both the Apple Mail and another set of boxes for Gmail. Both get all mail and when I delete from one, it deletes from the other. How can I get rid of the dup

    Hi,
    According to your descriptioin, I don't think this is system problem, it should be Intel driver problem. It would be contact Intel to confirm this issue whether this is their driver problem.
    Roger Lu
    TechNet Community Support

  • When I try to use siri to book an appointment the last step when she says "do you want me to shedule that for you" I say yes and then she says "Sorry I can't do that, very frustrating. Do I have to turn on another setting or something?

    When I try to use siri to book an appointment the last step when she says "do you want me to shedule that for you" I say yes and then she says "Sorry I can't do that, very frustrating. Do I have to turn on another setting or something?

    Hello BassoonPlayer,
    Since you are using one of the the school's Macbooks, it is quite possible that the time and date are not properly set on the computer that you are using.  FaceTime will not work if you do not have the proper time zone set up for the location that you are in.  This past week, there were a two other Macbook users I've helped by simply telling them to set the Date/Time properly.  By the way, you described your problem very well, which makes it easier for us to help you.  Hope this solves your problem -- if not, post back and I can suggest other remedies.
    Wuz

  • I have lost my install disks, will I have to pay for another set? :o[

    Will I have to pay for another set of disks if I have lost mine. I set my computer up after reinstalling it and cant friggin' think where the disks are now. But I want the iLife '08 suite on it now! :o[
    Is there a way I can get them for free from apple or will i have to pay? :o[

    Well... Apple is certainly under no obligation to cover the cost of the DVDs and shipping because you lost yours... However, they will ship you a new set for a nominal fee. Just give them a call. Be sure to have your serial number handy as the restore media is machine specific.

  • My iPad suddenly stopped connecting to my home network. It shows the network to. Choose from but there is no IP address or other information on the network page. It is set on DHCP and proxy is set at auto. Do I have another setting wrong?

    My iPad suddenly stopped working with my home network.  It shows the network to choose from but will not connect. When I look at details in that network it does not show IP address or any other info for the network.  Setting is on DHCP and http proxy is set on auto. Network is active and can connect on wife's iPad and other home computers.  Do I have another setting wrong?

    Some things to try first:
    1. Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.
    2. Go to Settings>Wi-Fi and turn Off. Then while at Settings>Wi-Fi, turn back On and chose a Network.
    3. Change the channel on your wireless router (Auto or Channel 6 is best). Instructions at http://macintoshhowto.com/advanced/how-to-get-a-good-range-on-your-wireless-netw ork.html
    4. Go into your router security settings and change from WEP to WPA with AES.
    5.  Renew IP Address: (especially if you are droping internet connection)
        •    Launch Settings app
        •    Tap on Wi-Fi
        •    Tap on the blue arrow of the Wi-Fi network that you connect to from the list
        •    In the window that opens, tap on the Renew Lease button
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    iOS 6 Wifi Problems/Fixes
    Fix For iOS 6 WiFi Problems?
    http://tabletcrunch.com/2012/09/27/fix-ios-6-wifi-problems/
    Did iOS 6 Screw Your Wi-Fi? Here’s How to Fix It
    http://gizmodo.com/5944761/does-ios-6-have-a-wi+fi-bug
    How To Fix Wi-Fi Connectivity Issue After Upgrading To iOS 6
    http://www.iphonehacks.com/2012/09/fix-wi-fi-connectivity-issue-after-upgrading- to-ios-6.html
    iOS 6 iPad 3 wi-fi "connection fix" for netgear router
    http://www.youtube.com/watch?v=XsWS4ha-dn0
    Apple's iOS 6 Wi-Fi problems
    http://www.zdnet.com/apples-ios-6-wi-fi-problems-linger-on-7000004799/
    ~~~~~~~~~~~~~~~~~~~~~~~
    How to Fix a Poor Wi-Fi Signal on Your iPad
    http://ipad.about.com/od/iPad_Troubleshooting/a/How-To-Fix-A-Poor-Wi-Fi-Signal-O n-Your-iPad.htm
    iOS Troubleshooting Wi-Fi networks and connections  http://support.apple.com/kb/TS1398
    iPad: Issues connecting to Wi-Fi networks  http://support.apple.com/kb/ts3304
    WiFi Connecting/Troubleshooting http://www.apple.com/support/ipad/wifi/
    How to Fix: My iPad Won't Connect to WiFi
    http://ipad.about.com/od/iPad_Troubleshooting/ss/How-To-Fix-My-Ipad-Wont-Connect -To-Wi-Fi.htm
    iOS: Connecting to the Internet http://support.apple.com/kb/HT1695
    iOS: Recommended settings for Wi-Fi routers and access points  http://support.apple.com/kb/HT4199
    How to Quickly Fix iPad 3 Wi-Fi Reception Problems
    http://osxdaily.com/2012/03/21/fix-new-ipad-3-wi-fi-reception-problems/
    iPad Wi-Fi Problems: Comprehensive List of Fixes
    http://appletoolbox.com/2010/04/ipad-wi-fi-problems-comprehensive-list-of-fixes/
    Fix iPad Wifi Connection and Signal Issues  http://www.youtube.com/watch?v=uwWtIG5jUxE
    Fix Slow WiFi Issue https://discussions.apple.com/thread/2398063?start=60&tstart=0
    How To Fix iPhone, iPad, iPod Touch Wi-Fi Connectivity Issue http://tinyurl.com/7nvxbmz
    Unable to Connect After iOS Update - saw this solution on another post.
    https://discussions.apple.com/thread/4010130
    Note - When troubleshooting wifi connection problems, don't hold your iPad by hand. There have been a few reports that holding the iPad by hand, seems to attenuate the wifi signal.
    ~~~~~~~~~~~~~~~
    If any of the above solutions work, please post back what solved your problem. It will help others with the same problem.
     Cheers, Tom

  • Why does the "Home" button open another set of tabs ontop of my existing?

    when I use an existing tab to go to another web site and then want to return to my original tabs I hit the home button and instead of reloading all my home screen tabs it opens another set of tabs along with the ones that are currently up. IE ,I have -5- tabs that open on start up. If I hit the home key I will then have -10- whci are duplicates of the one that are up. In IE the home key just takes me back to the tabs that open on start up. Do I have something set wrong?? I am a new user of Firefox. Thanks!!

    When you hit the Home button the active tab is reloaded with the first of your homepages and the other 4 homepages will open in new tabs; IE does that differently. Sorry, there is no setting in Firefox to change that action. There might be an add-on available to change that action, but I can't point you to it as I am comfortable with the current way Firefox does that (but then again I only have 2 homepages).

  • I need another pair of eyes.... my loops have got me twisted!

    Hey I'm trying to put together a basic tic tac toe game without using any classes. I've written enough code to allow one person to choose a valid position and for next to do so as well. So the game begins and the first player is asked to choose a position on the board,... you select a valid space between 1 and 9, otherwise you have to choose again, after you enter a valid number between 1 and 9 and second bit of code takes the integer value you've entered and converts it into a string for us to compare against the position. Since the 3X3 array is initialized to the numbers 1-9 corresponding with the positions the user selects, if anything other than the number entered appears in the position, the spot has previously been filled and the user is supposed to be prompted to select another position. So... getting back to the problem, after the user selects a bad position the code jumps back up to the top instead of executing the specific error code i tried to have triggered. Along the way you'll notice I've that I've commented out entire blocks of code with some ideas that I've had the have pretty much brought me back to the same place. I feel I've been looking at this thing for too long and i need some fresh perspective. I'm sure I'll be kicking myself when one you nobles points out my flaw.
    By the way player 2 code differs from player one so choose a base and let me know which approach works best.
    thanks for the consideration
    import java.util.Scanner; // importing the scanner to be able to accept user input
    public class ticTacToe { // matches the name of the file "ticTacToe.java"
         public static void main(String[] args) { //declaring the main class
    // *** Beginning: declaring all variables and objects ***
              Scanner keyboard = new Scanner (System.in); //creating the scanner object to accept user input
              char [][] board = new char [3][3];
              int row, column, i ,j;
              int userInput;
              char userInputChar;
              boolean emptySpotTest = false;
              //boolean userInputTest;
    // *** End: declaring all variables and objects ***
    // *** Beggining of Header ***
              System.out.println("X O X - Welcome to Benjamin's Tic Tac Toe Game - O X O\n");
              System.out.println("This Game has been designed to be played by two players.");
              System.out.println("As usual, one person will be player X and the other O.");
              System.out.println("When you choose where you'd like to place your piece enter a number between 1 and 9.\n");
              System.out.println(" 1 | 2 | 3 ");
              System.out.println("---|---|--- ");
              System.out.println(" 4 | 5 | 6 ");
              System.out.println("---|---|--- ");
              System.out.println(" 7 | 8 | 9");
    //*** End of Header ***
              //Initialize all of the elements in the array
              for(i = 0; i < 3; i++){
              board [0] = Integer.toString(i + 1).charAt(0);
                   for(i = 0; i < 3; i++){
                   board [1][i] = Integer.toString(i + 4).charAt(0);
                        for(i = 0; i < 3; i++){
                        board [2][i] = Integer.toString(i + 7).charAt(0);
                   for (i = 0; i < 3; i++){
                             System.out.printf( " %c | %c | %c", board[i][0], board[i][1], board[i][2]);
                             if (i != 2) System.out.print("\n---|---|---\n");
    int moveCounter = 0; //used to count the number of moves to trigger a test for a winner
    while (moveCounter >= 0){ //starting a game
         while (moveCounter % 2 == 0){ //finding out if player 1 should go
              emptySpotTest = false; //initialize the test to negative to be sure to run the tests every time we go in the above while loop
                   do{ //get an integer between 1 and 9 from the user
                        System.out.print("\nPlayer X please choose your spot on the board: ");
                        userInput = keyboard.nextInt();
                   } while (userInput < 1 || userInput > 9);
                   // figure out what position the player has selected
                   row = (userInput - 1) / 3;
                   column = (userInput - 1) % 3;
                   userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                   // finished converting the position to a string
              do{     
              if (board [row][column] == userInputChar){
              board [row][column] = 'X';
              moveCounter++;
                   else{
              while (emptySpotTest = false) {
                   System.out.print("Error: Player X, please enter a position that has not been taken: ");
                   userInput = keyboard.nextInt();
    //               figure out what position the player has selected
                   row = (userInput - 1) / 3;
                   column = (userInput - 1) % 3;
                   userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                   // finished converting the position to a string
                   if (board [row][column] == userInputChar){
                        board [row][column] = 'X';
                        emptySpotTest = true;
                        moveCounter++;
                   }else emptySpotTest = false;
              } while (emptySpotTest = false);
                        do{
                                            System.out.print("Error: Player X, please enter a position that has not been taken: ");
                                            userInput = keyboard.nextInt();
                                       } while (userInput < 1 || userInput > 9);
                                            //figure out what position the player has selected
                                            row = (userInput - 1) / 3;
                                            column = (userInput - 1) % 3;
                                            userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                                            // finished converting the position to a string
                                            if (board [row][column] == userInputChar){
                                                 board [row][column] = 'X';
                                                 emptySpotTest = true;
                                                 moveCounter++;
                                            }else emptySpotTest = false;
                        } //end of else statement
              //} while (emptySpotTest = false); //end of while for 2nd test
         }//end of while statement for palyer 1
    while (moveCounter % 2 != 0){ //finding out if player 2 should go
              emptySpotTest = false; //initialize the test to negative to be sure to run the tests every time we go in the above while loop
                   do{ //get an integer between 1 and 9 from the user
                        System.out.print("\nPlayer O please choose your spot on the board: ");
                        userInput = keyboard.nextInt();
                   } while (userInput < 1 || userInput > 9);
                   // figure out what position the player has selected
                   row = (userInput - 1) / 3;
                   column = (userInput - 1) % 3;
                   userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                   // finished converting the position to a string
              do{     
              if (board [row][column] == userInputChar){
              board [row][column] = 'O';
              moveCounter++;
                   else{
                        emptySpotTest = false;
              } while (emptySpotTest = false);
                             do{
                                  if (emptySpotTest = false){
                                       do{
                                            System.out.print("Error: Player O, please enter a position that has not been taken: ");
                                            userInput = keyboard.nextInt();
                                       } while (userInput < 1 || userInput > 9);
                                            //figure out what position the player has selected
                                            row = (userInput - 1) / 3;
                                            column = (userInput - 1) % 3;
                                            userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                                            // finished converting the position to a string
                                            if (board [row][column] == userInputChar){
                                                 board [row][column] = 'O';
                                                 emptySpotTest = true;
                                                 moveCounter++;
                                            }else emptySpotTest = false;
                             }while (emptySpotTest = false);
              } //end of while statement for palyer 2
    }//end of gamecounter while
    }//end of public static void main
    }//end of public class ticTacToe
              //begin player 2 code
              while (moveCounter % 2 != 0){ //finding out if player 2 should go
                   emptySpotTest = false; //initialize the test to negative to be sure to run the tests every time we go in the above while loop
                        do{ //get an integer between 1 and 9 from the user
                             System.out.print("\nPlayer O please choose your spot on the board: ");
                             userInput = keyboard.nextInt();
                        } while (userInput < 1 || userInput > 9);
                        // figure out what position the player has selected
                        row = (userInput - 1) / 3;
                        column = (userInput - 1) % 3;
                        userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                        // finished converting the position to a string
                   if (board [row][column] == userInputChar){
                   board [row][column] = 'O';
                   emptySpotTest = true;
                   moveCounter++;
                   else {
                             do{
                                  do{
                                  System.out.print("Error: Player O, please enter a position that has not been taken: ");
                                  userInput = keyboard.nextInt();
                                  } while (userInput < 1 || userInput > 9);
                                  //figure out what position the player has selected
                                  row = (userInput - 1) / 3;
                                  column = (userInput - 1) % 3;
                                  userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                                  // finished converting the position to a string
                                  if (board [row][column] == userInputChar){
                                       board [row][column] = 'O';
                                       emptySpotTest = true;
                                       moveCounter++;
                                  }else emptySpotTest = false;
                             }while (emptySpotTest = false);
                   } //end of else statement
              }//end of gamecounter while
         }//end of public static void main
    }//end of public class ticTacToe
              if (board[row][column] == userInputChar){ //test condition for the while statement directly below
                   board [row][column] = 'X'; //mark the spot with an X if it's empty
                   emptySpotTest = true; //set the boolean to to true meaning the spot is empty
                   moveCounter++; //test code
                   System.out.print(emptySpotTest); //test code
                   System.out.println(" " + board[row][column]); //test code
              else {
                   emptySpotTest = false;
              System.out.print(emptySpotTest); //test code
              System.out.println(" " + board[row][column]); //test code
              while (emptySpotTest = false){
                   do{
                        System.out.print("Error: Player X, please enter a position that has not been taken: ");
                        userInput = keyboard.nextInt();
                   } while (userInput < 1 || userInput > 9);
                   if (board[row][column] == userInputChar){
                        board [row][column] = 'X'; //mark the spot with an X if it's empty
                        System.out.print(emptySpotTest); //test code
                        System.out.println(" " + board[row][column]); //test code
                        emptySpotTest = true; //set the boolean to to true meaning the spot is empty
                        moveCounter++; //test code
                        System.out.print(emptySpotTest); //test code
              } //this segment of code is run after the user initially enters the number than it checks to see if
              //the space is free if not it keep looing until it's satisfied
              for (i = 0; i < 3; i++){
                   System.out.printf( " %c | %c | %c", board[i][0], board[i][1], board[i][2]);
                   if (i != 2) System.out.print("\n---|---|---\n");
              //moveCounter++; //increment the move counter
              while (moveCounter % 2 != 0){ //finding out if player 2 should go
                   emptySpotTest = false;
                   do{ //get an integer between 1 and 9 from the user
                   System.out.print("\nPlayer O please choose your spot on the board: ");
                   userInput = keyboard.nextInt();
                   } while (userInput < 1 || userInput > 9);
                   // figure out what position the player has selected
                   row = (userInput - 1) / 3;
                   column = (userInput - 1) % 3;
                   userInputChar = Integer.toString(userInput).charAt(0); //convert the users input positions into a char to match the array type
                   if (board[row][column] == userInputChar){ //test condition for the while statement directly below
                        board [row][column] = 'O'; //mark the spot with an X if it's empty
                        emptySpotTest = true; //set the boolean to to true meaning the spot is empty
                        System.out.print(emptySpotTest); //test code
                        System.out.println(" " + board[row][column]); //test code
                   else {
                        emptySpotTest = false;
                   while (emptySpotTest = false){
                        do{
                             System.out.print("Error: Player O, please enter a position that has not been taken: ");
                             userInput = keyboard.nextInt();
                        } while (userInput < 1 || userInput > 9);
                        if (board[row][column] == userInputChar){
                             board [row][column] = 'O'; //mark the spot with an X if it's empty
                             System.out.print(emptySpotTest); //test code
                             System.out.println(" " + board[row][column]); //test code
                             emptySpotTest = true; //set the boolean to to true meaning the spot is empty
                             System.out.print(emptySpotTest); //test code
                   } //this segment of code is run after the user initially enters the number than it checks to see if
                   //the space is free if not it keep looing until it's satisfied
                   System.out.println(board[row][column]);
                   System.out.println(emptySpotTest); //test code
                   System.out.print("\n");
                   for (i = 0; i < 3; i++){
                        System.out.printf( " %c | %c | %c", board[i][0], board[i][1], board[i][2]);
                        if (i != 2) System.out.print("\n---|---|---\n");
                   System.out.print("\n");
                   moveCounter++; //increment the move counter
              System.out.print("\n" + moveCounter);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    I suggest you try using a debugger to step through the program to see what it is doing.
    This will help you understand what you program does.
    I also suggest you try formatting your code in a readable manner or using a code formatter to do this for you.

  • Clear loaded pictures in xml gallery to load another set

    i cannot figure how to unload my already populated xml gallery, before loading new content :
    here the functions i want :
    //following 2 functions will be called by a button :
    // removes previously placed objects
    function clearLoadedPictures():void {
    // Load another ,xml to load new pictures set - ok : works fine
    function LoadNewPictures():void {
            i_g = 0;
               // xml data
                var xml_gallery:XML                = new XML();
                var xml_gallery_List:XMLList        = new XMLList;
                // XML data loader...
                var xmlUrlReq:URLRequest   = new URLRequest("xml/gallery2.xml");// gallery2.xml will replace gallery.xml already loaded
                var xml_gallery_UrlLoader:URLLoader = new URLLoader(xmlUrlReq);
                xml_gallery_UrlLoader.addEventListener(Event.COMPLETE, xml_gallery_Complete);
                xml_gallery_UrlLoader.addEventListener(IOErrorEvent.IO_ERROR, xml_gallery_LoadFailed);
    here the xml gallery code :
    var _mc:item;
    var total:int;
    var i_g:int;
    var id:int;
    var btn_Gallery_Ready:Boolean;
    var speedX:Number;
    var spaceR:Number;
    var img_gallery_Loader:Loader;
    i_g = 0;
               // xml data
                var xml_gallery:XML                = new XML();
                var xml_gallery_List:XMLList        = new XMLList;
                // XML data loader...
                var xmlUrlReq:URLRequest   = new URLRequest("xml/gallery.xml");
                var xml_gallery_UrlLoader:URLLoader = new URLLoader(xmlUrlReq);
                xml_gallery_UrlLoader.addEventListener(Event.COMPLETE, xml_gallery_Complete);
                xml_gallery_UrlLoader.addEventListener(IOErrorEvent.IO_ERROR, xml_gallery_LoadFailed);
                bottom24.gallery.content_mc.addEventListener(MouseEvent.ROLL_OVER, startScroll);
                bottom24.gallery.content_mc.addEventListener(MouseEvent.ROLL_OUT, stopScroll); //
    // xmlComplete function
            function xml_gallery_Complete(e:Event):void
            xml_gallery = XML(e.target.data); //
                xml_gallery_List = xml_gallery.item;  // <item> in gallery.xml
                total = xml_gallery_List.length();
                spaceR = xml_gallery.attribute("space"); // specified in gallery.xml file as is : <gallery space="119" speed="0.2">
                speedX = xml_gallery.attribute("speed");
                init_gallery();
            function xml_gallery_LoadFailed(e:IOErrorEvent):void {
                trace("Load Failed: " + e);
            function init_gallery()  //
                //bottom.gallery.content_mc.itemHolder_mc.
                _mc = new item(); //
                _mc.alpha = 0;
                //_mc.imgMask_mc.scaleY = 0;  // condition pour apparition des timbres ds la gallery - OLD
                _mc.imgMask_mc.alpha = 0; // condition pour apparition des timbres ds la gallery - NEW
                _mc.x = i_g * spaceR;
                _mc.btn.id = i_g;
                _mc.btn.mouseChildren = false;
                bottom24.gallery.content_mc.itemHolder_mc.addChild(_mc);
                Tweener.addTween(_mc, {alpha:1, time:0.8, transition:"easeOutExpo"});
                _mc.online_mc.alpha = 0; //invisible sans roll over
                if (xml_gallery_List[i_g].url != "")
                    _mc.btn.buttonMode = true;
                    _mc.online_mc.visible = true;
                    btn_Gallery_Ready = true;
                else
                    _mc.btn.buttonMode = false;
                    _mc.online_mc.visible = false;
                    btn_Gallery_Ready = false;
            var imgRequest:URLRequest = new URLRequest (xml_gallery_List[i_g].image); //
             img_gallery_Loader = new Loader(); // var imgLoader:Loader;
                img_gallery_Loader.load(imgRequest); //
                img_gallery_Loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imgLoading);
                img_gallery_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, img_gallery_Complete);
                i_g++;
            function imgLoading(event:ProgressEvent):void // tiny preloader in bottom thumbs pics
        _mc.preloader_mc.width = Math.round(img_gallery_Loader.contentLoaderInfo.bytesLoaded / img_gallery_Loader.contentLoaderInfo.bytesTotal * 100);
            function img_gallery_Complete(event:Event):void
                _mc.imgHolder_mc.addChild(img_gallery_Loader);
                Tweener.addTween(_mc.imgHolder_mc, {_saturation:0.9, time:0.6});// desaturate scrolling thumbs
                //_mc.imgHolder_mc.alpha = 0.5; // test
                // apparition des timbres ds la gallery, ici fade in : - NEW
                Tweener.addTween(_mc.imgMask_mc, {"alpha":1, delay:i_g / 20, time:0.4, transition:"easeOutExpo"});// test
                // apparition des timbres ds la gallery, ici image apparait de haut en bas : - OLD
                //Tweener.addTween(_mc.imgMask_mc, {"scaleY":1, delay:i_g / 10, time:1, transition:"easeOutExpo"});
                // la ligne de preloader qui diminue vers la gauche :
                Tweener.addTween(_mc.preloader_mc, {"scaleX":0, delay:0, time:1, transition:"easeOutExpo"});
                _mc.btn.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
                _mc.btn.addEventListener(MouseEvent.ROLL_OUT, onMouseOut);
                _mc.btn.addEventListener(MouseEvent.CLICK, onMouseClick);
                if (i_g < total)
                    init_gallery();
    thanks

    hi,
    back to work,
    then i used a loop in the first clear function:
    var n:int = 0;
                  while (n < xml_gallery_List.length() -1) {
                      bottom24.gallery.content_mc.itemHolder_mc.removeChildAt(n); //
                    i++;
    and it remove all my previously loaded pictures,but it throw me an error :
    RangeError: Error #2006: The supplied index is out of bounds.
    at flash.display: DisplayObjectContainer/removeChildAt()
    it seems error come from the removeChildAt, but i can't figure out what's wrong
    i've tried to replace removeChildAt(n); by removeChild(n); and the loop crash Flash software....
    any suggestion ?

  • Split Rows in to another set as columns in sql ?

    Hi,
    I have a sample data..
    Id
    ENAME
    GRADE
    1
    MILLER         
    2
    2
    CLARK          
    4
    3
    KING           
    7
    4
    ADAMS          
    5
    5
    FORD           
    1
    6
    JAMES          
    6
    7
    MARTIN         
    10
    8
    ALLEN          
    3
    9
    BLAKE          
    8
    10
    REDDY
    1
    I would like to split 5 rows in to another column set like this..
    Id
    ENAME
    GRADE
    Id1
    ENAME1
    GRADE1
    1
    MILLER         
    2
    6
    JAMES          
    6
    2
    CLARK          
    4
    7
    MARTIN         
    10
    3
    KING           
    7
    8
    ALLEN          
    3
    4
    ADAMS          
    5
    9
    BLAKE          
    8
    5
    FORD           
    1
    10
    REDDY
    1
    Please help me on this.
    Thank you.

    You may be much better doing this at front end
    But if you want to implement it in sql server this is the way to go
    SELECT MAX(CASE WHEN GrpNo = 0 THEN Id END) AS Id,
    MAX(CASE WHEN GrpNo = 0 THEN Ename END) AS ENAME,
    MAX(CASE WHEN GrpNo = 0 THEN Grade END) AS Grade,
    MAX(CASE WHEN GrpNo = 1 THEN Id END) AS Id1,
    MAX(CASE WHEN GrpNo = 1 THEN Ename END) AS ENAME1,
    MAX(CASE WHEN GrpNo = 1 THEN Grade END) AS Grade1,
    MAX(CASE WHEN GrpNo = 2 THEN Id END) AS Id2,
    MAX(CASE WHEN GrpNo = 2 THEN Ename END) AS ENAME2,
    MAX(CASE WHEN GrpNo = 2 THEN Grade END) AS Grade2,
    FROM
    SELECT *,
    (ROW_NUMBER() OVER (ORDER BY Id)-1)/5 AS GrpNo,
    (ROW_NUMBER() OVER (ORDER BY Id)-1) % 5 AS Seq
    FROM Table
    )t
    GROUP BY Seq
    ORDER BY Seq
    to make it dynamic see
    http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Maintenance Windows - I need another pair of eyes

    Hello Everyone,
    I am looking for a second pair of eyes to ensure I have this process down 100%. The goal is a scheduled client computer reboot following the May patch install.
    Assign a 12 hour maintenance window on my client computer collection.
    Enforce a 10 hour reboot cycle (initial notification).
    Enforce a non-dismissible notification at the 3 hour mark.
    I am running some final tests today. Below is my maintenance window:
    This is the reboot behavior I assigned:
    My first test this morning resulted in the computer say it was going to reboot in 90 minutes! I double checked the computer only had the single maintenance window applied and the client settings were assigned and set properly. I'm concerned there may be
    some hidden maximum value on the restart settings.

    Ensure that you don't have any applications/updates that are set to install and reboot outside of maintenance windows.
    If my answer helped you, check out my blog:
    DeployHappiness. Subscribe by
    RSS or
    email. 

  • I have two time capsules (1TB, 2TB) and want to use one for another set of Macs (my Family). How do I set both up and keep all the Macs from joining both Time Capsules?

    I Have two Time Capsules (1TB and 2TB) and want to set one for business and the other for family - networking seperate Macs to each.

    Both should be plugged into the network with ethernet.. if at all possible.
    If you have a router already then both bridged otherwise one set to router and one to bridge.
    How do you access the TC? Ethernet or wireless?
    Are they located in the same area?
    You could set different wireless networks.. if they use wireless.. this is nice easy way to do it.
    You can set user account in the TC you want the business one to join with.. that will prevent access by the family.
    So there is a number of ways.. none are particularly secure btw.. the TC is a home not a business device.. if anybody wants access they press the reset for one second.. pofff all the passwords are default for 5min.. to allow people who forget their password to get access.
    On ML you can encrypt TM backups.. this is better for security if that is the problem.. and still use different user profile to prevent access.

Maybe you are looking for