My object won't acknowledge the "new" command.

Okay I have this class called Die that is suppose to simulate a die with the added behaviour that it ceases to operate if 6 is rolled. But that problem is that when ever I try to declare multiple instances of the Die class with the new command the Die objects becomes copies of each other and are not independent. So change to one object alters all the other objects. I don't know why it is doing this. I am including the code of my Die class and my die population class which has the array which I am trying to populate with independent Die objects.
public class Die {
     private static int numTosses;
     private static boolean alive;
     public Die() {
          numTosses = 0;
          alive = true;
     public int getNumTosses() {
          return numTosses;
     public boolean alive() {
          return alive;
     public void toss() {
          if (alive == true){
               numTosses++;
               int dieToss = (int)(6*Math.random())+1;
               System.out.println("Die toss result " + dieToss);
               if (dieToss == 6){
                    alive = false;
                    System.out.println("Dead");
     public String toString() {
          return "Number of Tosses thus far\t" + numTosses;
public class DicePopulation {
     //instance variables
     private Die []dice;
     private int numAlive;
     private int numTossesAll;
     //constructor
     public DicePopulation (int numDice){
          dice = new Die[numDice];
          numAlive = numDice;
          numTossesAll = 0;
          for (int i = 0; i<numDice; i++){
               dice[i] = new Die();
     public int getNumAlive (){
          return numAlive;
     public int getNumTossesAll (){
          return numTossesAll;
     public void tossAll (){
          for (int i = 0; i<dice.length; i++){
               boolean diceStatus = dice.alive();
               System.out.println("Die index " + i + " Die Status " + diceStatus);
               if (diceStatus == true){
                    System.out.println("Tossed Die Number " + i);     
                    dice[i].toss();
                         if (dice[i].alive() == false){
                              numAlive--;
          numTossesAll++;
     public String toString (){
          return "number times all tossed\t" + numTossesAll + "\tnumber alive\t" + numAlive;

Couldn't the problem also be that he has declared
the object "dice" outside if the intialization loop
causing each instance in the array to be a copy?
I know that the static would cause a problem but
couldn't the other be the case as well?Huh?
The declaration of dice seems correct to me, remember our hero here used 'i' as loop variable and you should know that a bracketed 'i' formats text in italics here, so this loop actually readsfor (int k = 0; k < dice.length; k++) {
    dice[k] = new Die();
} i.e. no copies ...

Similar Messages

  • Itunes installed but it won't open the new version- any advise

    itunes installed but it won't open the new version- any advise

    Hello goreckim,
    Thanks for the question, and welcome to Apple Support Communities.
    I understand you are having some issues with iTunes on your Mac Pro. You may want to isolate the issue further by testing to see if it persists in a new user account:
    Isolating an issue by using another user account
    http://support.apple.com/kb/TS4053
    You can also try starting iTunes in safe mode:
    iTunes: Troubleshooting issues with third-party iTunes plug-ins
    http://support.apple.com/kb/TS3430
    Thanks,
    Matt M.

  • I'm trying to change my ICloud e-mail to match the one associated with the Apple ID? Can someone tell me how to do this? Seems like the phone won't accept the new one, the message states "you already have acct associated....."  (a given!!)  I need help !!

    I'm trying to change my ICloud e-mail to match the one associated with the Apple ID? Can someone tell me how to do this? Seems like the phone won't accept the new one, the message states "you already have acct associated....."  (a given!!)  I need help !!

    You made a purchase and exhausted the credit on your card before it processed. All purchases are final. Contact iTunes Store support. You need to settle up before you can purchase or download anything else.

  • I cant' sync my ipod because it says"The iPod cannot be used because it requires iTunes version 10.6.3 or later. I can't download it because my MAC is version 10.5.8 and it won't accept the newer version of itunes. Any suggestions?

    I cant' sync my ipod because it says"The iPod cannot be used because it requires iTunes version 10.6.3 or later. I can't download it because my MAC is version 10.5.8 and it won't accept the newer version of itunes. Any suggestions?

    If you're using a fourth generation or earlier iPod touch, click here and download the software.
    If you're using a fifth generation iPod touch and an Intel Mac, buy Mac OS X 10.6 from the online Apple Store and run Software Update.
    If you're using a fifth generation iPod touch and a PowerPC Mac, buy a newer computer.
    (73046)

  • My itunes won't install the new itunes.  I keep getting error messages that seem to be linked to MobileMe service which I don't even know what it is.

    my itunes won't install the new itunes.  I keep getting error messages that seem to be linked to MobileMe service which I don't even know what it is.

    Read this:
    iTunes 11.1.4 for Windows - Unable to install or open - MSVCR80 issue

  • I want to install the latest version of i tunes. I recieve an error that the MSI file is missing. It won't load the new version and I can not delete the software either. HELP!

    I have a windows computer running xp. I can not load the latest version of I tunes. I receive an error message that the 'msi" file can not be found. I can not delete I tunes for the same reason.
    HELP

    ItIt is the the ituens msi file
    From: Apple Support Communities Updates
    [email protected]
    Sent: Monday, February 27, 2012 3:40 PM
    To: escow 39
    Subject: - Re: I want to install the latest version of
    i tunes. I recieve an error that the MSI file is missing. It won't load the
    new version and I can not delete the software either. HELP!
      <http://images.apple.com/support/images/emails/apple_logo_gray.gif>
    <https://discussions.apple.com/index.jspa> Apple Support Communities
    Re: I want to install the latest version of i tunes. I recieve an error that
    the MSI file is missing. It won't load the new version and I can not delete
    the software either. HELP!
    created by b noir <https://discussions.apple.com/people/b+noir>  in iTunes
    for Windows - View the full discussion
    <https://discussions.apple.com/message/17708214?ac_cid=142432#17708214

  • My JSP engine won't load the new source from my page

    My JSP engine won't load the new source from my page, even know I saved it, and I restarted apache, and resaved the files again, no dice! It must be running off of cash, it's not in my browser cash I cleared it out too, what else can I do?

    Tomcat checks to see if the JSP has changed since it was last compiled with you request that page... So, if the file is updated, it should recompile it. Are you sure that when you update the page, you're updating the same copy of the page? (the location defined in the server.xml file)

  • I just got iTunes 11.0. I'm used to being able to return to the beginning of a song by hitting 'enter'. What's the new command for skipping to the head of a song?

    I just got iTunes 11.0. From all the previous versions I'm used to being able to return to the beginning of a song by hitting 'enter'. What's the new command for skipping to the head of a song?

    Mmmmmm. Works OK for me. I've tried every variation I can think of. Play from playlist, play from library, shuffle on, shuffle off, single song repeat on/off, playlist repeat on/off.
    WAIT !!   Now I've found it  !!  It happens when I have the sidebar hidden and play a playlist from the PLAYLIST pane. Hitting Enter then takes me to the FIRST song in the playlist.
    WAIT AGAIN !!! In the time it took to write the above, it changed again and works properly. Well properly is not really true. It works if I stay in the PLAYLIST pane. If I switch to the SONGS, ALBUMS or ARTISTS pane, enter does nothing. BUT, if I switch to the GENRES pane, enter starts the first song there. AND, if I've switched away from the PLAYLIST pane and switch back, enter then starts the first song in the playlist.
    WOW !! That was a crazy ride. I think we can safely say that there is something awry.

  • My daughter has an iPod Nano but just received an iPod Touch 5G but iTunes won't recognise the new device. What can we do?

    My daughter has an iPod Nano but just received an iPod Touch 5G but iTunes won't recognise the new device. What can we do?

    iOS: Device not recognized in iTunes for Mac OS X
    or
    iOS: Device not recognized in iTunes for Windows
    You need iTunes 11.1 or later on the computer.
    Does the iPod charge?

  • Does the new command 2 binary format work with Apple Push Notification Service? I receive an invalid response status code of 128.

    Does the new command 2 binary format work with Apple Push Notification Service? I am sending 2 messages with the same payload to 2 different devices. None of the messages display on either of the devices. It seems that at least 3 should have been displayed. For my first device, I received a response with an invalid status code of 128 and the message identifier is 2 indicating that the first message was OK. However no message was displayed on the phone. For the second device, I did not receive any error response, but no message was displayed on the device.
    Does ANS perform any validation on the message identifier? The Local and Push Notification Programmin Guide says the message identifier is:
    An arbitrary, opaque value that identifies this notification. This identifier is used for reporting errors to your server.
    I know that the device tokens are valid because the same tokens work when I use the legacy basic or enhanced formats. The phones display the messages correctly when I send to ANS using the old ANS message format.
    Here is the data and the response:
    Sent to ANS: 2 0 0 0 158 1 0 32 120 107 166 143 171 157 143 169 70 135 12 135 246 142 64 224 244 44 116 4 154 65 115 192 206 28 189 56 174 0 172 16 2 0 23 123 34 97 112 115 34 58 123 34 97 108 101 114 116 34 58 34 65 66 67 34 125 125 3 0 4 0 0 0 2 4 0 4 83 7 119 141 5 0 1 5 1 0 32 120 107 166 143 171 157 143 169 70 135 12 135 246 142 64 224 244 44 116 4 154 65 115 192 206 28 189 56 174 0 172 16 2 0 23 123 34 97 112 115 34 58 123 34 97 108 101 114 116 34 58 34 65 66 67 34 125 125 3 0 4 0 0 0 3 4 0 4 83 7 119 141 5 0 1 5
    ANS returned an error: 8 128 0 0 0 2
    Sent to ANS: 2 0 0 0 158 1 0 32 4 239 182 26 13 237 170 136 41 243 181 57 120 208 135 19 101 102 212 70 55 244 251 255 160 125 82 9 10 143 72 17 2 0 23 123 34 97 112 115 34 58 123 34 97 108 101 114 116 34 58 34 65 66 67 34 125 125 3 0 4 0 0 0 5 4 0 4 83 7 119 147 5 0 1 5 1 0 32 4 239 182 26 13 237 170 136 41 243 181 57 120 208 135 19 101 102 212 70 55 244 251 255 160 125 82 9 10 143 72 17 2 0 23 123 34 97 112 115 34 58 123 34 97 108 101 114 116 34 58 34 65 66 67 34 125 125 3 0 4 0 0 0 6 4 0 4 83 7 119 147 5 0 1 5
    ANS did not return a response.

    Hello, can you please help me ?
    You specified sample payload here:
    TerrellFromLockhart wrote:
    I finally got this to work. The picture in the Programming Guide is very confusing. The solution was to prefix every message's frame data with command 2 and that messsage's frame data length. Here is a sample:
    ANS frame: 2 0 0 0 77 1 0 32 120 107 166 143 171 157 143 169 70 135 12 135 246 142 64 224 244 44 116 4 154 65 115 192 206 28 189 56 174 0 172 16 2 0 21 123 34 97 112 115 34 58 123 34 97 108 101 114 116 34 58 34 63 34 125 125 3 0 4 0 0 0 2 4 0 4 83 7 199 195 5 0 1 10 2 0 0 0 77 1 0 32 120 107 166 143 171 157 143 169 70 135 12 135 246 142 64 224 244 44 116 4 154 65 115 192 206 28 189 56 174 0 172 16 2 0 21 123 34 97 112 115 34 58 123 34 97 108 101 114 116 34 58 34 63 34 125 125 3 0 4 0 0 0 3 4 0 4 83 7 199 195 5 0 1 10 2 0 0 0 77 1 0 32 120 107 166 143 171 157 143 169 70 135 12 135 246 142 64 224 244 44 116 4 154 65 115 192 206 28 189 56 174 0 172 16 2 0 21 123 34 97 112 115 34 58 123 34 97 108 101 114 116 34 58 34 63 34 125 125 3 0 4 0 0 0 4 4 0 4 83 7 199 195 5 0 1 10
    About to read response at Thu Feb 20 15:40:20 CST 2014
    SocketTimeoutException
    2 - is clearly command
    0 0 0 77 - frame length
    1 - item Id
    what's 0 32 ? According to this page https://developer.apple.com/library/ios/documentation/NetworkingInternet/Concept ual/RemoteNotificationsPG/Chapters/Commu…
    Item id  should be followed by item length. But item length is obviously greater than 32 because device token's length is 32. Can you please explain why 0 32 were used? and do you have any insight on item id meaning ?

  • My iPod had music on it previously from my old computer but won't sync the new music I bought on my new laptop? The songs I bought appear in the library, but they won't sync onto my iPod?

    I'm going on a hike tomorrow with my dad and I'd been reluctant to download iTunes on my new laptop but finally decided to install it so I could have new music for the trip.  I bought nearly ninety new songs, all of which appeared in my library, and on my account they are shown with my old songs.  But my iPod isn't syncing the new music?  Really I planned to start from scratch and not have them together, but that would be fine if they would just download.  I don't understand.  They're in my library, but won't download to my iPod. 

    Hi avmary11,
    If your are having issues with your iPod not being recognized by iTunes (but it is being recognized by the computer), you may find the following article helpful:
    iPod: Appears in Windows but not in iTunes
    http://support.apple.com/kb/ts1363
    Regards,
    - Brenden

  • The 2.1.3 Software update won't work, the new version of iTunes won't download. Please help.

    For several months now I have not been able to find a solution to either of these two problems. When I have the Apple Software Update program open and I click update, it loads for a second and then goes back to the usual page saying to update. It will not update. I have also tried, multiple times, to install the new current version of iTunes and that won't work either. I've tried to repair iTunes by going to Control Panel > Programs > Repair and it still won't work. Please help because I'm trying to download a new app but it requires the new version of iTunes. I am using a Windows Vista and I'm this is for my 4th generation iPod touch.

    Did you try simply downloading the latest version of iTunes using the link below and then installing it on top of the older version?
    http://www.apple.com/itunes/download/
    B-rock

  • My processer won't run the new update ?

    I have an iBook G4. After downloading the new version of Firefox it will not run so I have to continue with the older version. I continuously get messages telling me my version is out of date which is getting annoying.
    Apple want me to buy a new computer at about £1000 which I can't afford.even if I could, the old programmes won't run on new processors so I would the have to buy them all again. not a good AD for apple? Greed rears it's ugly head!!!.
    Thanks in anticipation. Regards Geoff Downend.

    hello GeoffDd, the tenfourfox project develops a browser that is based on the current firefox for your hardware plattform: http://www.floodgap.com/software/tenfourfox/

  • Updated to 7.0.6 on my iPhone 5s and now my phone is all out of whack. It won't sync the new playlists I added after the update though when it's plugged into iTunes it says it's synced. Help please!

    So I updated my iPhone 5s to version 7.0.6 yesterday, and now my iPhone music isn't working properly. It won't sync the playlists that I added after the update though when it's plugged in on iTunes it says that the music is synced. When I select a song in a playlist on the phone it shuffles through the playlists for like 3 seconds and picks a totally different song to play. I tried reinstalling iTunes, I tried restoring the iPhone, is it just a bug with the update? Nothing works. Any solutions are welcome.

    DFU mode? How do I do that? So far the only thing I can do is hold down both buttons to power it on and nothing is on the screen and it wont reconize on my computer....

  • IMovie '11 won't import the new clips from iPhoto

    I uploaded some footage from my Sanyo VPC-HD2000A to my iMac. All of the new clips were copied into iPhoto. (I never deleted anything from my camcorder so they're all there as well, for now.)
    The problem: I opened up iMovie '11 and the new uploaded clips that went to iPhoto did not get imported into iMovie '11. I see the clips and have played one of them. They're there in iPhoto.
    How can I get those newly uploaded clips to iMovie '11?
    I just now noticed that when I click the camera icon in iMovie '11, the folder that I made and that has those new clips in iPhoto is indeed there...... but when I click to see what's inside the folder, there is nothing. Yet I know that the clips are inside that folder when I look in iPhoto.
    Can someone lead me out of this?
    This seems like a good time for me to go downstairs for a snack.
    -L
    Message was edited by: Lorna from Hawaii
    Message was edited by: Lorna from Hawaii

    The problem is solved. At someone's request, I looked yet again at the folder titled "iPhoto Videos" in the Event Library (See screen shot.) When I noticed that the dates on that folder included today's date, this time I looked more carefully and scrolled all the way to the bottom of the page, where happily, I found the videos that I had uploaded from my Sanyo VPC-HD2000A earlier today. I thought that all of the videos would go underneath the iPhoto folder and end up looking like the 2011 folders (See screen shot again.)
    If all of those folders and videos under/in the 2011 folder are there, I am wondering why such folders from today's upload did not get added there somehow in some form. Why are they all still in the iPhoto videos folder?
    Could iMovie '11 be in error? Because as it is now, although I am happy that iMOvie '11 did indeed get my videos from iPhoto, it bothers me that it did not also format those folders below the way the other folders are. The inconsistency of actions bothers me. Now I cannot be sure that looking in one spot will show all of my videos.
    Message was edited by: Lorna from Hawaii
    Message was edited by: Lorna from Hawaii

Maybe you are looking for

  • CF MX 7 Installation Errors on Linux

    I have been planning to put a production web server up using Fedora Core 5 and Cold Fusion MX 7 for some time - Mainly because the updates on FC5 are done so much more frequenntly than most other versions of Linux I've used. So far, the only producti

  • Error on Cataloging: Tuxedo Art Workbench

    Hi. I have a Cobol application in Mainframe and I want to migrate it to Tuxedo, using Tuxedeo Art Workbech When I execute the catalog (refine r4z-catalog), i get this error: Loading /migracion/art_wb12110/COBROS/source/sql-system-COBROS.pob at 09:52:

  • If you want to access the PowerShell 3.0 Help in another language please vote for my Connect suggestion!

    All my Windows operating Systems are set to use the UI Culture: German With Update-Help or Save-Help you can download PowerShell help in different (any) language by use of the –UICulture parameter. Update-Help –UICulture en-US Because my Windows OS i

  • Garageband custom "user-loops" files missing

    I'm using Garageband '09 (Version 5.1 (398) and I am having trouble locating my custom "user loops" files. I know that custom made apple loops are saved in Library/Audio/Apple Loops/User Loops I have about 100 loops saved in the folder, but in Garage

  • Time stamp to number conversion

    Hi All, I notice in Labview 7.0 the 'Get Date/Time to Seconds' and 'Seconds to Date/Time' now output a Time Stamp rather than actual seconds. There is a 'To Time Stamp" standard vi in the conversion pallet that converts a number (seconds) to a time s