Help with set(index, object) please / new to java

private static void setDobject(Rectangle [] setrect)
          LinkedList<Rectangle> rects = new LinkedList<Rectangle>();
          Rectangle myrectangle = new Rectangle(9.0,9.0);                                                                  
             rects.set(1,myrectangle);
          for(Rectangle x : setrect)
               System.out.print("Rectangle: ");
               System.out.println(x.getLength() + " by " + x.getWidth());
          }  //End of for loop
     }  //End of unsorted
     }  the other previous code works, i have used the add(object) and it works here is the code for that:
private static void addDobject(Rectangle [] addrect)
          LinkedList<Rectangle> rects = new LinkedList<Rectangle>();
          Rectangle myrectangle = new Rectangle(9.0,9.0);                                                                  
             rects.add(myrectangle);
             for(Rectangle x : rects)
               System.out.print("Rectangle: ");
               System.out.println(x.getLength() + " by " + x.getWidth());
          }  //End of for loop
          System.out.println();
     }  //End of unsorted
this is the output error it is giving me :
Part 1 : An Array List of Rectangles
Enter length or 999 to exit: 3
Enter width: 2
Enter length or 999 to exit: 1
Enter width: 2
Enter length or 999 to exit: 10
Enter width: 20
Enter length or 999 to exit: 999
Rectangle: 3.0 by 2.0
Rectangle: 1.0 by 2.0
Rectangle: 10.0 by 20.0
Display Object with added item
Rectangle: 3.0 by 2.0
Rectangle: 1.0 by 2.0
Rectangle: 10.0 by 20.0
Rectangle: 9.0 by 9.0
Displaying Objects with SET item
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size:
0
at java.util.LinkedList.entry(LinkedList.java:365)
at java.util.LinkedList.set(LinkedList.java:328)
at Lab11.setDobject(Lab11.java:129)
at Lab11.main(Lab11.java:78)
Press any key to continue...
finally here is the Rectangle class i'm using:
public class Rectangle
    private double length;     // Instance variables
    private double width;
    public Rectangle(double l, double w)  // Constructor method
        length = l;
        width = w;
    } // end Rectangle constructor
    public double getLength()             // getter 
         return length;
    } // end getLength
     public double getWidth()             // getter 
         return width;
    } // end getWidth
    public void setLength(double l)      // setter 
         length = l;
    } // end setLength
     public void setWidth(double w)     // setter 
         width = w;
    } // end setWidth
     public double calculateArea()         // calculation method
        return length * width;
    } // end calculateArea
    public void displayRectangle()         // display method
        System.out.println("Rectangle Length = " + length);
        System.out.println("Rectangle Width = " + width);               
    } // end displayRectangle
} // Rectangle ClassHope you can help guys! thanks!

LinkedList<Rectangle> rects = new LinkedList<Rectangle>();rects is an empty LinkedList at this point. It has no elements added to it.
rects.set(1,myrectangle);So you can't set the item at index 1 (the 2nd element in the list) because it doesn't even exist. You need to add items to it.

Similar Messages

  • HT1904 help with setting ipod restrictions please.

    Help please, I have been charged for apps that I did not approve although apple has credits my credit card how do I make sure this does not happen again. I was given a site to visit: support.apple.com/kg/HT4213 although I am still no the wiser.
    Thank you.

    Usually, it's In-Apps that these purchases come from (children).
    iTunes Store: About In-App Purchases
              http://support.apple.com/kb/HT4009
    iOS: Understanding Restrictions
              http://support.apple.com/kb/HT4213
    iTunes: Using Parental Controls
              http://support.apple.com/kb/ht1904

  • Help with context index with /, -, @

    Hi all!
    I have just start work with oracle. I have a problem with context index. Please help me. My problem is :
    I have two column 'name' and 'address'. I index two column with context index (for example : Two index have name is 'Index1' and 'Index 2' ). I set parameter ('STOPLIST ctxsys.empty_stoplist') and i insert four rows such as : ('A','80/3 cong hoa'), ('B','80-3 cong hoa'), ('C','80@3 cong hoa'), ('D','80 3 cong hoa'). But when i execute this select :
    select * from tablename where contains(address, '3 cong hoa') > 0
    Result will return to me 4 rows But i just want one rows is ('D', '80 3 cong hoa').
    I know oracle will convert character '/', '-', '@' to space so result will return 4 rows and i don't know how to oracle keep character '/', '-', '@' when oracle index. I just want to add with 'Index2' for column 'address' and i don't want to add with 'Index1' for column 'name'
    Please help me, and thanks for your attention

    So you want "/", "-" and "@" to link tokens, but you want "." to break numeric tokens?
    OK, we can do that - though it seems a slightly odd requirement.
    There are two special characters NUMJOIN and NUMGROUP which are used for purely numeric tokens. The default will vary by locale, but for English-speaking locales the defaults are "." and "," - so a number such as 1,234,567.89 will be treated as a single token. In French (and other) speaking locales, they are reversed since numbers are normally written as 1.234.567,89.
    If you want to disable these NUMJOIN and NUMGROUP characters, so that numbers are always split into component tokens, then you can set both of the to the space character (it won't allow NULL or '', which would be more logical in my opinion).
    drop table foo;
    create table foo (bar varchar2(200));
    insert into foo values ('80/3 cong hoa');
    insert into foo values ('80-3 cong hoa');
    insert into foo values ('80@3 cong hoa');
    insert into foo values ('80 3 cong hoa');
    insert into foo values ('80.3 cong hoa');
    exec ctx_ddl.drop_preference('foo_lexer')
    exec ctx_ddl.create_preference('foo_lexer', 'basic_lexer')
    exec ctx_ddl.set_attribute('foo_lexer', 'PRINTJOINS', '/-@')
    exec ctx_ddl.set_attribute('foo_lexer', 'PRINTJOINS', '/-@')
    exec ctx_ddl.set_attribute('foo_lexer', 'NUMJOIN', ' ')
    exec ctx_ddl.set_attribute('foo_lexer', 'NUMGROUP', ' ')
    create index foo_index on foo(bar) indextype is ctxsys.context
    parameters ('lexer foo_lexer');
    select * from foo where contains (bar, '3 cong hoa') > 0;Output is:
    BAR
    80 3 cong hoa
    80.3 cong hoa

  • I need help with setting up my Sun Java Studio Creator

    Hello all, i need help with setting up the Studio Creator, i"m new to all that staff so is there anyone to help me just a little with all that if yes email me at [email protected] or get me on AOL Instant Messanger with the screen name: wretch17
    thanks :-)

    Hi,
    Welcome to the Creator community! Thanks for your interst in Sun Java Studio Creator. Please feel free to post any question related to creator on this forum .
    Take a look the creator website at
    http://developers.sun.com/prodtech/javatools/jscreator/
    CreatorTeam

  • Help with taking my membership to new my computer

    help with taking my membership to new my computer

    Hi there,
    I would like to inform you One CC membership can be used on two machines . These two computers can be Windows, Mac OS, or one each.
    If you install on a third computer, it will request you to de-activate on the other two computers.  You can then reactivate one of the previous two computers, and use Creative Cloud apps on it.
    Please follow the below mentioned steps :
    1) Open [https://creative.adobe.com ]
    2) Click on SIgn in
    3) Enter your Adobe ID and Password
    4) Click on "Download Centre" on Left top corner
    And you would be able to download all the applications on your new machines.
    Let me know it it helps.
    Regards
    Eshant

  • Can anyone help with setting up AirPrint on my iPhone 4

    Can anyone help with setting up AirPrint on my iPhone 4.  Printer is ready.

    you have a compatable printer correct? http://support.apple.com/kb/ht4356
    if you do may i introduce you to a hassel free app for your mac called printopia i use it also very easy to set up and use
    http://www.udeo.com/mac/printopia/
    hope thats helped
    Goody

  • Purchased extreme to replace modem/router DSL used telephone cord need help with set up

    Prior to purchasing Airport Extreme had a standard modem/ wireless router from ATT for DSL. I have two macbooks both dropped connections while online with older modem.
    Airport Extreme purchased to correct connection issues I need help with set up. The older modem just used telephone cord. I tried to use telephone with extreme it did not work.
    How do I get extreme to work as the modem and router ?

    How do I get extreme to work as the modem and router ?
    you can't. the extreme is only a router. you need a separate modem (or disable the wireless part of your old router and use it as a modem - if that's possible).

  • I need help with setting up time machine for backup

    I would like help with setting up time machine for backup.

    You will need an external hard drive (formatted for a Mac).
    Then you plug it in and go to system preferences>time machine and select the external HD and turn it on.
    The backups are automatic.
    Barry

  • New computer ~ Help with setting up

    Hi everyone, Newbie here!
    I am going to set my new computer up tomorrow. The computer I am using at present was installed and set up by someone else so this will be a great learning curve for me. Also I had Infinity installed by the engineer.
    Is everything I need to install relating to my broadband available to download? What do I need altogether? I spoke to a BT chap on the phone and he said he would help by remote access. I am a bit nervous of this!
    I need to ensure my computer is safe and secure and it all seems technically daunting. Norton security came with  my Microsoft Office package. Is this better than McAfee (Net Protect Plus), do I need both? What about a key code scrambler  (someone mentioned this to me). As you can see I need reassurance and help arghhhhhhh.
    A step by step guide would be great!
    Thanks
    Solved!
    Go to Solution.

    It is best not to install any of the BT software, just connect your computer to the BT Home hub using an Ethernet cable, or by using the wireless key, if its a wireless connected computers.
    See http://bt.custhelp.com/app/answers/detail/a_id/14964/~/getting-started-with-wireless
    Using a direct cable connection is best, if you want to get maximum speed.
    I would not allow anyone remote access, but if you have no choice, and cannot resolve the issue any other way, then make sure that it is as a direct result of you ringing BT, and not some random person ringing you at home, pretending to be from BT or even Microsoft.
    Many people have been caught out by that type of call, and had their computer infected with spyware.
    If you already have a trial version of Norton Security, then by all means use it until it expires, then uninstall it.
    After that, you have the choice of using the free Microsoft Security Essentials, which is preferred by many forum members, or using BTs Netprotect which is free with some broadband packages. This has been known to make computers run more slowly though.
    That is all you need.
    If you have any problems, then please return here.
    If you have any problems with BT Infinity, then please visit the Infinity board on this forum.
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

  • New to Java and need help with this program..please!

    I'd really appreciate any helpful comments about this program assignment that I have to turn in a week from Friday. I'm taking a class one night a week and completely new to Java. I'd ask my professor for help, but we can't call him during the week and he never answers e-mails. He didn't tell us how to call from other classes yet, and I just can't get the darn thing to do what I want it to do!
    The assignment requirements are:
    1. Change a card game application that draws two cards
    and the higher card wins, to a Blackjack application
    2. Include a new class called Hand
    3. The Hand class should record the number of draws
    4. The application should prompt for a number of draws
    5. The game is played against the Dealer
    6. The dealer always draws a card if the dealer's hand total is <= 17
    7. Prompt the player after each hand if he wants to quit
    8. Display the total games won by the dealer and total and the total games wond by the player after each hand
    9. Display all of the dealer's and player's cards at the
    end of each hand
    10. Player has the option of drawing an additional card after the first two cards
    11. The Ace can have a value of 11 or 1
    (Even though it's not called for in the requirements, I would like to be able to let the Ace have a value of 1 or an 11)
    The following is my code with some comments about a few things that are driving me nuts:
    import java.util.*;
    import javax.swing.*;
    import java.text.*;
    public class CardDeck
    public CardDeck()
    deck = new Card[52];
    fill();
    shuffle();
    public void fill()
    int i;
    int j;
    for (i = 1; i <= 13; i++)
    for (j = 1; j <= 4; j++)
    deck[4 * (i - 1) + j - 1] = new Card(i, j);
    cards = 52;
    public void shuffle()
    int next;
    for (next = 0; next < cards - 1; next++)
    int rand = (int)(Math.random()*(next+1));
    Card temp = deck[next];
    deck[next] = deck[rand];
    deck[rand] = temp;
    public final Card draw()
    if (cards == 0)
    return null;
    cards--;
    return deck[cards];
    public int changeValue()
    int val = 0;
    boolean ace = false;
    int cds;
    for (int i = 0; i < cards; i++)
    if (cardValue > 10)
    cardValue = 10;
    if (cardValue ==1)     {
    ace = true;
    val = val + cardValue;
    if ( ace = true && val + 10 <= 21 )
    val = val + 10;
    return val;
    public static void main(String[] args)
    CardDeck d = new CardDeck();
    int x = 3;
    int i;
    int wins = 1;
    int playerTotal = 1;
    do {
    Card dealer = (d.draw());
    /**I've tried everything I can think of to call the ChangeValue() method after I draw the card, but nothing is working for me.**/
    System.out.println("Dealer draws: " + dealer);
    do {
    dealer = (d.draw());
    System.out.println(" " + dealer);
    }while (dealer.rank() <= 17);
    Card mine = d.draw();
    System.out.println("\t\t\t\t Player draws: "
    + mine);
    mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
    do{
    String input = JOptionPane.showInputDialog
    ("Would you like a card? ");
    if(input.equalsIgnoreCase("yes"))
         mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
         playerTotal++;
         else if(input.equalsIgnoreCase("no"))
    System.out.println("\t\t\t\t Player stands");
         else
    System.out.println("\t\tInvalid input.
    Please try again.");
    I don't know how to go about making and calling a method or class that will combine the total cards delt to the player and the total cards delt to the dealer. The rank() method only seems to give me the last cards drawn to compare with when I try to do the tests.**/
    if ((dealer.rank() > mine.rank())
    && (dealer.rank() <= 21)
    || (mine.rank() > 21)
    && (dealer.rank() < 22)
    || ((dealer.rank() == 21)
    && (mine.rank() == 21))
    || ((mine.rank() > 21)
    && (dealer.rank() <= 21)))
    System.out.println("Dealer wins");
    wins++;
         else
    System.out.println("I win!");
    break;
    } while (playerTotal <= 1);
    String stop = JOptionPane.showInputDialog
    ("Would you like to play again? ");
    if (stop.equalsIgnoreCase("no"))
    break;
    if (rounds == 5)
    System.out.println("Player wins " +
    (CardDeck.rounds - wins) + "rounds");
    } while (rounds <= 5);
    private Card[] deck;
    private int cards;
    public static int rounds = 1;
    public int cardValue;
    /**When I try to compile this nested class, I get an error message saying I need a brace here and at the end of the program. I don't know if any of this code would work because I've tried adding braces and still can't compile it.**/
    class Hand()
    static int r = 1;
    public Hand() { CardDeck.rounds = r; }
    public int getRounds() { return r++; }
    final class Card
    public static final int ACE = 1;
    public static final int JACK = 11;
    public static final int QUEEN = 12;
    public static final int KING = 13;
    public static final int CLUBS = 1;
    public static final int DIAMONDS = 2;
    public static final int HEARTS = 3;
    public static final int SPADES = 4;
    public Card(int v, int s)
    value = v;
    suit = s;
    public int getValue() { return value; }
    public int getSuit() { return suit;  }
    public int rank()
    if (value == 1)
    return 4 * 13 + suit;
    else
    return 4 * (value - 1) + suit;
    /**This works, but I'm confused. How is this method called? Does it call itself?**/
    public String toString()
    String v;
    String s;
    if (value == ACE)
    v = "Ace";
    else if (value == JACK)
    v = "Jack";
    else if (value == QUEEN)
    v = "Queen";
    else if (value == KING)
    v = "King";
    else
    v = String.valueOf(value);
    if (suit == DIAMONDS)
    s = "Diamonds";
    else if (suit == HEARTS)
    s = "Hearts";
    else if (suit == SPADES)
    s = "Spades";
    else
    s = "Clubs";
    return v + " of " + s;
    private int value; //Value is an integer, so how can a
    private int suit; //string be assigned to an integer?
    }

    Thank you so much for offering to help me with this Jamie! When I tried to call change value using:
    Card dealer = (d.changeValue());
    I get an error message saying:
    Incompatible types found: int
    required: Card
    I had my weekly class last night and the professor cleared up a few things for me, but I've not had time to make all of the necessary changes. I did find out how toString worked, so that's one question out of the way, and he gave us a lot of information for adding another class to generate random numbers.
    Again, thank you so much. I really want to learn this but I'm feeling so stupid right now. Any help you can give me about the above error message would be appreciated.

  • Help with setting up a new user account

    What is the solution to file sharing on the same computer with two separate User Accounts? I want to set up a new user account, but I want to be able to access the Documents, Music, Movies and Pictures folders, as well as others possibly in the original account. Is this easy to do, and/or possible without messing around too much with permissions and the like?
    Thanks,
    Mac

    Setting up read only access for other users is pretty easy. Just change a few permissions and you're done. I'll show you how to do it if you like.
    Setting up full read+write, well, that's a little trickier. It's because of how Mac OS X sets up permissions on new files and folders. By default, any new file or folder that is created gets full read and write permissions for the user that created it, and read-only for everyone else.
    Changing permissions on the two users' home folders to that both users have full read+write for everything inside can be done, and it's not too hard. The problem is when new files are added - they will be read only for the other user. So the procedure has to be repeated again and again, every time a new file is created.
    Having said that, it is possible to set up Access Control Lists on certain folders, so that anything that is created in to copied to the folder automatically gets read+write for both users. This is a little trickier to set up, but it can be done. I use it to share iMovie projects, and an iPhoto library between my and my wife's user accounts and it works well.
    The latter solution requires entering some scary-looking Terminal commands. If you bro is scared to ask for help in web forums then he sounds likely to be scared of Terminal commands too. :/

  • TS1702 help with a bad app please! new to this

    black smudges appeared all over it so I deleted it and went and reloaded it. the problem is that I paid for no ads, and now they want me to pay again, though there was something worng with it. I am new to all this so any help would be appreciated.

    Contact the app developer.
    Or...
    Go to the page where you purchased "No ads" before, and see if the app has a "Restore purchases button."
    Or...
    Buy it again and contact iTunes Support to try to get refunded...
    Refunds from the App Store or iTunes Store

  • Help with project/folder setup for new flex project??

    Hello all,
      I need help deciding how to set up my projects for a new flex application we're developing.
    We have an in-house custom java/jsp "framework". This framework has JSP pages for administering applications that are built using this framework. One part of the framework generates all java base and model objects from our database tables to be used in the new application.
    The new application will have a back-office part (Adobe AIR) and a web facing part (Adobe Flex).  Both the AIR and Flex parts of the application need to access the java model objects via AS3 classes (I believe I'll do this using remoteobject).
    My questions are as follows:
    After I create the base and model AS3 classes that remoteobject with the java classes can I put these in a common library project so both my AIR and Flex app can access common AS3 code.  I feel I should do this to keep from duplicating code by copying the AS3 classes in both my AIR and Flex projects.  Can you give my any examples or links to information on how to do this??
    I plan to also create a common java project for all base and model objects generated from my db tables so that the common library project with AS3 classes could remoteobject interface with the java classes in the java project. I would like to keep all of my business logic in the java model classes.  Does this seem appropriate for the projects/setup listed above?
    Here are the projects I think I need in Flex Builder.
    FlexWebApp
    AIRBackOfficeApp
    JavaApp - Common
    AS3FlexLibraryApp - Common
    The FlexWebApp and AIRBackOfficeApp will reference the AS3FlexLibraryApp and the AS3FlexLibraryApp will remoteobject to the java classes in JavaApp.
    Any help or direction with this is greatly appreciated.
    Thanks,
    Whitney

    Hi,
    Please post only once (do not post same thread across multiple forums).
    help with Financials setup from very basics...
    Re: help with Financials setup from very basics...
    Regards,
    Hussein

  • Need help with " Number guessing game " please?

    This is what teacher requires us to do for this assignment:
    Write a program that plays a simple number guessing game. In this game the user will think of a number and the program will do the guessing. After each guess from the program, the user will either indicate that the guess is correct (by typing �c�), or that the next guess should be higher (by typing �h�), or that it should be lower (by typing �l�). Here is a sample output for a game. In this particular game the user thinks of the number 30:
    $java GuessingGameProgram
    Guess a number between 0 and 100
    Is it 50? (h/l/c): l
    Is it 25? (h/l/c): h
    Is it 37? (h/l/c): l
    Is it 31? (h/l/c): l
    Is it 28? (h/l/c): h
    Is it 29? (h/l/c): h
    Is it 30? (h/l/c): c
    Thank you for playing.
    $
    This program is implementing a binary search algorithm, dividing the range of possible values in half with each guess. You can implement any algorithm that you want, but, all things being equal, binary search is the best algorithm.
    Write the program so that the functionality is split between two classes: GuessingGameProgram, and NumberGuesser.
    GuessingGameProgram will only be used for its main function. It should instantiate a NumberGuesser, and it will be responsible for the loop that notifies the user of the next guess, reads the �h�, �l�, or �c� from the user, and sends an appropriate message to the number guesser accordingly.
    The guesses themselves should all be generated by the NumberGuesser class. Here is a diagram of the members and methods for the class. Notice that the members are unspecified. Feel free to give your NumberGuesser class any members (which we have also been calling fields, or instance variables) that you find useful. Make them all private.
    NumberGuesser
    NumberGuesser(int upperLimit, int lowerLimit)
    int guess()
    void higher()
    void lower()
    The constructor should take two integer arguments, a lower and upper bound for the guesses. In your program the constructor will be called with bounds of 0 and 100.
    The guess method should return the same value if it is called more than once without intervening calls to the lower or higher methods. The class should only change its guess when it receives a message indicating that its next guess should be higher or lower.
    Enjoy. Focus your attention on the NumberGuesser class. It is more interesting than the GuessingGameProgram class because it is a general-purpose class, potentially useful to anybody who is writing a number guessing game. Imagine, for instance, that a few weeks from now you are asked to write a number guessing game with a graphical Java Applet front end. If you NumberGuesser class is well written, you may be able to reuse it without any modifications.
    I'm new to JAVA and I'm set with my 2nd homework where I'm so confused. I know how to do something of this source in C language, but I'm a bit confused with Java. This is the code me and my classmate worked on, I know it's not 100% of what teacher asked, but is there any way possibly you guys could help me? I wrote this program if the game is played less then 10 times, thought I would then re-create a program without it, but now I'm confused, and my class book has nothing about this :( and I'm so confused and lost, can you please help? And out teacher told us that it's due the end of this week :( wish I knew what to do. Thank you so so much.
    Here's the code:
    import java.text.*;
    import java.io.*;
    class GuessingGame
    public static void main( String[] args ) throws IOException
    BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ) );
    int guess = 0, limit = 9, x = 0, n, a = 0 ;
    double val = 0 ;
    String inputData;
    for ( x = 1; x <= 10; x++)      //number of games played
    System.out.println("round " + x + ":");
    System.out.println(" ");
    System.out.println("I am thinking of a number from 1 to 10. ");
    System.out.println("You must guess what it is in three tries. ");
    System.out.println("Enter a guess: ");
    inputData = stdin.readLine();
    guess = Integer.parseInt( inputData );
    val = Math.random() * 10 % limit + 1;     //max limit is set to 9
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(0);               //format number of decimal places
    String s = nf.format(val);
    val = Integer.parseInt( s );
         for ( n = 1; n <= 3; n++ )      //number of guess's made
                   if ( guess == val)
                        System.out.println("RIGHT!!");                    //if guess is right
                        a = a + 1;
                        System.out.println("You have won " + a + " out of " + x + " rounds");
    System.out.println(" ");
    n = 3;
    continue;
              if (n == 3 && guess != val)                         //3 guesses and guess is wromg
                        System.out.println("wrong");
    System.out.println("The correct number was " + val);
                        System.out.println("You have won " + a + " out of " + x + " rounds");
    System.out.println(" ");
    continue;
                   //how close guess is to value
                   if ( guess == val - 1 || val + 1 == guess) //Within 1
                   System.out.println("hot");
         else if ( guess == val - 2 || val + 2 == guess) // Within 2
                   System.out.println("warm");
              else
                   System.out.println("cold");                         // Greater than 3
         inputData = stdin.readLine();
         guess = Integer.parseInt( inputData );
    //ratings
    if ( a <= 7)
         System.out.println("Your rating is: imbecile.");
    else if ( a <= 8)
         System.out.println("Your rating is: getting better but, dumb.");
    else if (a <= 9)
         System.out.println("Your rating is: high school grad.");
    else if ( a == 10)
         System.out.println("Your rating is: College Grad.!!!");

    Try this.
    By saying that, I expect you ,and your classmate(s), to study this example and then write your own. Hand it in as-is and you'll be rumbled as a homework-cheat in about 20ms ;)
    When you have an attempt where you can explain, without refering to notes, every single line, you've cracked it.
    Also (hint) comment your version well so your tutor is left with the impression you know what you're doing.
    In addition (huge hint) do not leave the static inner class 'NumberGuesser' where it is. Read your course notes and find out where distinct classes should go.
    BTW - Ever wonder if course tutors scan this forum for students looking for help and/or cheating?
    It's a double edged sword for you newbies. If you ask a sensible, well researched question, get helpful answers and apply them to your coursework, IMHO you should get credit for doing that.
    On the other hand, if you simply post your assignment and sit there hoping some sucker like me will do it for you, you should be taken aside and given a good kicking - or whatever modern educational establishments consider appropriate abmonishment ;)
    I'd say this posting is, currently, slap bang between the two extreemes, so impress us. Post your solution in the form you intend to hand it in, and have us comment on it.
    Good luck!
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    public class GuessingGame
         public static void main(String[] args)
              throws Exception
              BufferedReader reader= new BufferedReader(
                   new InputStreamReader(System.in));
              NumberGuesser guesser= new NumberGuesser(0, 100);
              System.out.println(
                   "\nThink of a number between 0 and 100, oh wise one...");
              int guess= 0;
              while (true) {
                   guess= guesser.guess();
                   System.out.print("\nIs it " +guesser.guess() +"? (h/l/c) ");
                   String line= reader.readLine();
                   if (line == null) {
                        System.out.println(
                             "\n\nLeaving? So soon? But we didn't finish the game!");
                        break;
                   if (line.length() < 1) {
                        System.out.println("\nPress a key, you muppet!");
                        continue;
                   switch (line.toLowerCase().charAt(0)) {
                        case 'h':  
                             guesser.higher();
                             break;
                        case 'l':     
                             guesser.lower();
                             break;
                        case 'c':
                             System.out.println("\nThank you for playing.");
                             System.exit(0);
                        default:
                             System.out.println(
                                  "\nHow hard can it be? Just press 'h' 'l' or 'c', ok?");
                             continue;
                   if (guess == guesser.guess()) {
                        System.out.println(
                             "\nIf you're going to cheat, I'm not playing!");
                        break;
         private static class NumberGuesser
              private int mLower;
              private int mUpper;
              private int mGuess;
              NumberGuesser(int lowerLimit, int upperLimit)
                   mLower= lowerLimit;
                   mUpper= upperLimit;
                   makeGuess();
              private void makeGuess() {
                   mGuess= mLower + ((mUpper - mLower) / 2);
              int guess() {
                   return mGuess;
              void higher()
                   mLower= mGuess;
                   makeGuess();
              void lower()
                   mUpper= mGuess;
                   makeGuess();
    }                  

  • Need help with flash player installation please !!!!

    Hello,
    I need help with my flash player installation because every time I access a movie this is the message I receive. 
    This content on Xfinity TV is not available for viewing with Chrome's "Incognito" mode. To play this video using Chrome, please view this page without "Incognito" mode.
    Still having problems? Try resetting your Flash player license.

    Incognito mode is a Google Chrome setting when you open a new window (Cmd+Shift+N on a Mac Ctrl+Shift+N on Windows) It opens a "private" window with no cookies and no tracking. The problem with it is that when you disable cookies, your license files are not sent to the site (whetehr it's YouTube or xFinity or any other that uses license files for paid content)  and it treats you as if you're a first time visitor. Paid videos won't play wihtout the cookies sending the license file info.
    This isn't a Flash Player setting. It's in Chrome. I did some research and according to Google, "Incignito" mode is off by default, and can ONLY be activate by the keyboard shortcut. There IS a way to disable it from the registry http://dev.chromium.org/administrators/policy-list-3#IncognitoModeAvailability

Maybe you are looking for