Stuck in array

I made one simple program, inside the program, I have array of 5. I've created 5 cards objects in array, each object has 2 variables inside(the suit and the value, e.g. 5 of hearts). now, i wanna compare whether there are 2 same cards, 2 same cards are not allowed, so I need to get each of the variable from 1 card and compare to another
I have no idea how to access each variable, can someone help me?
thanks

Hi SkY_bLu3,
The guys above me are absolutely right, but I suspect you don't know what a hash-code is... No harm in reading some of the article's yawmark mentioned, though!
A (really-and-far-too) simple implementation for your problem would be something like this:
* Card
public class Card {
    private String suit = "";
    private int value = -1;
    /** Constructor */
    public Card(String suit, int value) {
        this.suit = suit;
        this.value = value;
    public String getSuit() {
        return suit;
    public int getValue() {
        return value;
    /** Compare another card with 'this' card */
    public boolean equals(Card other) {
        return (other.getSuit().equals(this.suit)
                && other.getValue() == this.value);
    /** String representation of the Card */
    public String toString() {
        return "["+suit+", "+value+"]";
} // class CardTest it with this:
* TestCard
public class TestCard {
    public static void main(String[] args) {
        Card[] hand = new Card[5];
        String[] suits = {"Hearts", "Clubs", "Diamonds", "Spades"};
        /** fill the hand with cards */
        for(int j = 0; j < hand.length; j++) {
            Card c = new Card(suits[j%4], (j%4)+1);
            hand[j] = c;
        /** print the hand */
        for(int j = 0; j < hand.length; j++) {
            System.out.println(hand[j]);
        /** check the equals-method */
        for(int j = 1; j < hand.length; j++) {
            System.out.println(hand[0]+" equals "+hand[j]+"? "+hand[0].equals(hand[j]));
} // class TestCardGood luck!

Similar Messages

  • Stuck on array of array copy problem

    I've got one array, outputMatrix[][] which is bigger that array matrix[][], and I want to copy matrix into outputMatrix, but off set the copy by a certain amount (to the right by EXTRA_COLUMN_TEXT and down by EXTRA_ROW_TEXT)
    I've tried     for (int i = 0; i < matrix.length; i++ ) {
          System.arraycopy(matrix, 0, outputMatrix[i + EXTRA_ROW_TEXT], EXTRA_COLUMN_TEXT, matrix.length);
    but it fails (java.lang.ArrayStoreException
    ) everytime. What am I doing wrong. I'm really stuck :(

    for(int i=EXTRA_ROW_TEXT, m=0; i<(matrix.length+EXTRA_ROW_TEXT); i++, m++)
    for(int j=EXTRA_COLUMN_TEXT, n=0; j<(matrix(i).length+EXTRA_COLUMN_TEXT); j++, n++)
    outputMatrix(i)(j)=Matrix(m)(n);

  • Stuck with array problem

    Hi, I am new to programming with C # and wondering if
    anyone can help me with one thing.
    The only thing I got is this array of letters, but need to sort them
    int[] letters = { "c", "s", "a", "k", "x", "l", "j" };
    and then print and save the array in alphabetical order.
    But the thing is that I never have converted the letters to INT wich I
    would need to do in order to sort them with bubble sorting and
    then convert back to letters to print and save in the right
    order.
    How will this code / program look like? The whole thing.
    Thanks and much appreciated for help!
    If you want more information, ill answer as quick is possible!

    Almost the same code works even for bubble sorting strings. Just use the string.Compare method instead of the > operator:
    string[] letters = { "c", "s", "a", "k", "x", "l", "j" };
    string temp;
    for (int write = 0; write < letters.Length; write++)
    for (int sort = 0; sort < letters.Length - 1; sort++)
    if (string.Compare(letters[sort],letters[sort + 1]) == 1)
    temp = letters[sort + 1];
    letters[sort + 1] = letters[sort];
    letters[sort] = temp;
    And for chars:
    char[] letters = { 'c', 's', 'a', 'k', 'x', 'l', 'j' };
    char temp;
    for (int write = 0; write < letters.Length; write++)
    for (int sort = 0; sort < letters.Length - 1; sort++)
    if (letters[sort] > letters[sort + 1])
    temp = letters[sort + 1];
    letters[sort + 1] = letters[sort];
    letters[sort] = temp;
    Once again, please remember to mark helpful posts as answer to close the thread once you original question has been answered and start a new thread if you have a new question.
    Thank you, and i got a few more questions about this before ill mark this thread as answered.
    That codes u just sent me, whats the different between them, the string and char? They almost
    look the same except the string and char part.
    And then im wondering, how will i write down so i can see the results when im debugging it?
    Is it with Console.Write or WriteLine? I can't remember.

  • Stuck with array's NEED HELP!!!

    I have been working at this for two hours now and I need a someone else's opinion other than my own. I need to create a method that finds the row index of the row which contains the largest number divisible evenly by 6. and the column index of the column with the smallest sum. all in one method.
    This is what I have so far.
      public static int sum(int[][]arr, int numRow)
                  int[][] s;
                  s = new int[0][10];
                  int u = 0, largestevenindex = 0, largesteven = -99999, product = 0, sum = 0, i, j;
                  for(i=0;i<numRow;i++)
                    for(j=0;j<arr.length;j++)
    if(arr[i][j]%6==0 && arr[i][j]>largesteven) //To find the the row index of the largest number divisible by 6.
              largesteven = arr[i][j];
              largestevenindex = i;
         System.out.println(largesteven);
         System.out.println(largestevenindex);
         for(u=0;u<arr[i].length;u++) //I think I have to create another table and place the sums of the colums and then compare. Is there an easier way?
    s[0] = s[0][u]+arr[i][j];
         System.out.println(s[0][u]);
    return largestevenindex;
    This is the test file23 45 10 77 19 13 16
    52 34 71 19 88 65 3
    12 1 57 16 4 36 17
    9 22 31 27 8 25 12
    56 77 88 22 33 44 99
    6 21 16 89 4 37 48
    25 17 8 9 64 72 81
    95 26 5 73 18 92 66
    99 12 45 72 19 77 43
    11 71 26 34 81 7 45
    16 2 34 68 67 7 51
    19 52 4 56 51 95 12
    57 4 7 9 2 1 3
    Anyone have any tips for my code, or another way to do this. Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Your right flounder, I forget to add we are suppose to just find the product of the two index(smallest sum cloum index and largest row index divisible by 6)
             public static int sum(int[][]arr, int numRow)
                  int[][] s;
                  s = new int[0][10];
                  int u = 0, largestevenindex = 0, largesteven = -99999, product = 0, sum = 0, i, j;
                  for(i=0;i<numRow;i++)
                    for(j=0;j<arr.length;j++)
    if(arr[i][j]%6==0 && arr[i][j]>largesteven)
              largesteven = arr[i][j];
              largestevenindex = i;      
    return largestevenindex;
    This gets the row index of the highest number divisible by 6. How do I go about finding the colum index that has the smallest sum. any hints or clues. It has to be apart of this method, though.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Stuck with making my event structure examine if two arrays are equal

    Hi there, I'm new to labview. I'm trying to write an event structure; examining if one array equals another array. The program will carry on if they are equal, otherwise it will continue checking... Any help is appreciated.
    My program is attached.. It is eventually going to be a memory game when I get it working..
    Sequence 1, case structure 10 is were I'm stuck with the case structure.
    Thank you in advance
    Attachments:
    attempt 2.vi ‏18 KB

    Seems to me like you should implement a true State Machine.  This way you can repeat states and/or jump states as needed.
    State Machine
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • CAS ARRAY fail-over and emails stuck

    Dear all,
    for some reasons we are in Exchange Server Coexistance mode that is 1 Exchange 2003 Server and 2. Exchange 2010 servers.
    We have CAS array(node-1 And Node-2) and DAG in place , but the problem is whenever my Node-1 is down emails are getting stuck routing group connector on legacy server and Exchange 2010 to Exchange 2010 emails are working.
    oppositly
    when my Node-2 is down everything works.
    how do I FIX this ?
    TheAtulA

    Dear all,
    for some reasons we are in Exchange Server Coexistance mode that is 1 Exchange 2003 Server and 2. Exchange 2010 servers.
    We have CAS array(node-1 And Node-2) and DAG in place , but the problem is whenever my Node-1 is down emails are getting stuck routing group connector on legacy server and Exchange 2010 to Exchange 2010 emails are working.
    oppositly
    when my Node-2 is down everything works.
    how do I FIX this ?
    TheAtulA
    I assume the CAS also have the hub trasnport installed?
    Check the Routing Group Connector(s) (Get-RoutingGroupConnector) and ensure the source and destination transports include both CAS nodes, not just Node-1.
    If not, then use set-routinggroupconnector to set the correct source and target servers 
    https://technet.microsoft.com/en-us/library/aa998581(v=exchg.141).aspx
    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

  • Stuck on and array, trying to isolate a field

    Hello,
    I'm VERY new to JavaScript and am totally stuck. I'm building an editable order form in Adobe Acrobat and I'm trying to get Acrobat to add an array of fields together, isolating the last field that has to be multiplied by 8 in order to get a proper unit count. The last field is a multi-pack, so has to be mulitplied by 8. I've built all of the fields and they're numbered from .01 to .12, but Acrobat keeps changing the field that's being multiplied by 8 to the first (.01) field. There are about 50 different products in this form and I can't seem to get the formula I was given to work properly. Here's what I've been working with:
        var oField = this.getField('aerial');
        var p = 26;
        var n = 8
        aField = oField.getArray();
        var gSum = aField.shift().value;
        var fSum = 0; // variable for sum of individual qtys
        for(i = 0; i < aField.length; i++) {
            fSum += Number(aField[i].value); // add values
        event.value = (fSum * p) + (gSum * (p*n));
    I don't know anything about coding and I've been stuck on this for hours and just can't seem to get it right. Any help would be appreciated.
    thanks!

    The shift method will remove the first element of the array and return it. What you want to use is the pop method, so try changing the one line to:
    var gSum = aField.pop().value;

  • Stuck with this array

    so i have my code which makes the MC go to random places on the stage, but what i want is for the MC to go to each corner of the stage randomly, not all over the stage.
    think its the arrays that need to be edited but im not sure?
    any one have an answer?
    import flash.events.MouseEvent;
    addChild(btnPos1U);
    btnPos1U.x=btnPos1U.y=0;
    var positionA:Array=[[stage.stageWidth-btnPos1U.width,0],
                         [0,stage.stageHeight-btnPos1U.height],
                         [stage.stageWidth-btnPos1U.width,0],
                         [stage.stageWidth-btnPos1U.width,stage.stageHeight-btnPos1U.height]];
    var t:Timer=new Timer(2000,0);
    t.addEventListener(TimerEvent.TIMER,f);
    t.start();
    function f(e:TimerEvent):void{
    btnPos1U.visible = true
    btnPos1U.x=Math.floor(Math.random()*(stage.stageWidth-btnPos1U.width))
    btnPos1U.y=Math.floor(Math.random()*(stage.stageHeight-btnPos1U.height))
    btnPos1U.addEventListener(MouseEvent.CLICK,g)
    function g (e:MouseEvent):void
        btnPos1U.visible = false
        init();
        btnNeg1.addEventListener(MouseEvent.CLICK, EndUnlimited);
        btnNeg2.addEventListener(MouseEvent.CLICK, EndUnlimited);
        btnNeg3.addEventListener(MouseEvent.CLICK, EndUnlimited);
        btnNeg4.addEventListener(MouseEvent.CLICK, EndUnlimited);
        btnPos1U.addEventListener(MouseEvent.CLICK, on_press);
    function EndUnlimited (e:MouseEvent):void
        gotoAndPlay(102);
    stop();

    There is no "MC" in your code.  If you are talking about the button that gets randomly placed, that happens in the following two lines:
    btnPos1U.x=Math.floor(Math.random()*(stage.stageWidth-btnPos1U.width))
    btnPos1U.y=Math.floor(Math.random()*(stage.stageHeight-btnPos1U.height ))
    The array you speak of identifies the locations of the four corners of the stage, which is what you want to pick from I would guess.  Think thru what you have and what you want and figure out how to make use of what you have to get there.

  • Stuck at Detecting array....

    on my
    MSI K8N neo FSR nforce3 250Gb
    when ever my cpu is overclocked more than 10% i get the message
    NVIDIA Raid IDE Rom BIOS 4.81
    Detecting array....
    My system is
    Sempron 2600+
    512mb generic ram pc 2700
    200GB Sata HD
    Does any one know what is causing this problem? or how to fix it. semprons can OC like 50% stock cooling so that shouldn't be the problem.... some times i haven't gotten this problem once booted with 50% OC and was completely stable (prime95 24hours)
    could this be a faulty mobo?
    Thanks Max
    (please excuse any mistakes, i fail everything in english because of mistakes)
    note: i have disabled ide raid and it still happens, also tried reinstalling bios and every common fix like that

    thanks for help, sadly didn't work
    i disabled aggressive timings and loaded optimal defaults and still did it.... dam
    could it be ram timings? could i manualy change them? what would you recomend for my 512mb pc2700 generic ram

  • All the xml and arrays are getting NULL Problem

    Hello guys
    I am working on a project which uses xml loading, e4x and array manipulation extensively, and it was going good but now I got stuck on a strange problem.  Whole code was fine and application was working and responding in a desired way, but then mystourisly it stopped working and started to retun NULL values to almost all the actionscript (internal) Arrays and XML varibales.
    Now Whenever i load xml file and assign the loaded values to internal xml variables, internal values get only NULL instead of data.
    Same is the situation with Arrays, I created some components in mxml, and when i passed them to arrays by reference, code gets compiled successfully, but again Array has only null values [that code was working fine too]
    I am wondering if Adobe Flex did a silenced update or something similar and it is the result of that things !
    I am using Adobe Flex 3.2 with SDK 3.3 on windows Vista Ultimate.
    Please check this attached project, Import it and see if you face the same problem
    Thanks
    Link to Problem Project
    http://isolatedperson.googlepages.com/problemXperiment.zip
    Problem Screenshot
    http://isolatedperson.googlepages.com/xmlissue.JPG

    Use HTTPService to load the data. You'll have fewer problems.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application creationComplete="dataSvc.send();"
      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
         <mx:Script>
              <![CDATA[
                import mx.collections.XMLListCollection;
                import mx.rpc.events.ResultEvent;
                [Bindable] private var xlc:XMLListCollection;
                   private function loadXML(evt:ResultEvent):void{
                    xlc =  new XMLListCollection(evt.result.individual.@id as XMLList);
              ]]>
         </mx:Script>
         <mx:HTTPService resultFormat="e4x" result="loadXML(event)" url="alirazaTree.xml" id="dataSvc"/>
         <mx:ComboBox id="cbx" dataProvider="{xlc}"/>
    </mx:Application>

  • Empty string in an array :(

    Hi, im new here and stupid :D
    I have an assignment to do and im really stuck on this bit. I have 2 arrays, 1 of heights and 1 of towns -
    private int[] spotHeights = { 100,  // At 0 km
    120,120,150,120,200,200,210,220,230,240, // Heights at 1-10 km
    300,300,300,250,250,200,150,150,150,130, // Heights at 11-20 km
    120,120,150,120,200,200,210,220,230,240, // Heights at 21-30 km
    300,300,300,250,250,200,150,150,150,130, // Heights at 31-40 km
    120,120,150,120,200,200,210,220,230,240 }; // Heights at 41-50 km
    private String[] towns = { "Berwick",  // At 0 km
    "","Edinburgh","","","","Falkirk","","","","", // Towns at 1-10 km
    "","","","","","Stirling","","","","", // Towns at 11-20 km
    "","Doune","","","","","","Dunblane","","", // Towns at 21-30 km
    "","","","Ashfield","","","","Kinbuck","","", // Towns at 31-40 km
    "","","Perth","","","","","","","Aviemore" }; // Towns at 41-50 km
    What i have to do is draw a dot where there is a town on a sort of map thing. Only thing is i dont know how to check whether there is something in the array or not... I hope you understand what im asking and u can help me :D That would be great.
    Thanks
    Awe

    ok, in the second array, theres lots of "" and that means theres nothing in that part of the array. Well i need to know how to find out whether there is something in the arrays or not :/ hard to explain... i think its something like variable.equals[""] but that never works, maybe im doing it wrong.

  • Loops and arrays

    Hi
    I'm trying to write a loop that does the following :-
    Takes an array of index values that applies to a string adds one to the value of the index and then returns the character in this position.
    There are only four types of character within the string so I have tried to solve it with the following code:-
    for (int i=0; i < indexa.length; i++)
        if(genome.charAt(indexa[i] + 1) == 'a')
            indexia[i] += indexa;
    else if(genome.charAt(indexa[i] + 1) == 'c')
    indexic[i] += indexa[i];
    else if(genome.charAt(indexa[i] + 1) == 'g')
    indexig[i] += indexa[i];
    else if (genome.charAt(indexa[i] + 1) == 't')
    indexit[i] += indexa[i];
    I'm trying it this way but it does'nt seem to work - I've only succeeded in confusing myself - any tips would be much appreciated

    Sorry, I should have explained it better.
    The situation I've got is something like this:-
    I've got a string that looks something like this
    'aactgctcct'
    next - I've got four different arrays, each corresponding to the index of each character a, c, t and g
    so they look something like this
    indexa = {0,1}
    indexc = {2,5,7,8}
    indext = {3,6,9}
    indexg = {4}
    I am presently stuck at the next part - for which I have to return the character that is to the immediate right of the index value in the string that was analysed initially.
    e.g. for indexa ;
    0 = a
    1 = c
    for indexc;
    2 = t
    5 = t
    7 = c
    8 = t
    etc
    I don't know if this makes my predicament any clearer - I'm a genetics student this java is very new to me - I'm kinda muddling through but this bit has got me stumped !!!

  • Help with parallel arrays of different data types

    Hello all, I am having an issue with parallel arrays. My program requires me to read information from a text file into 4 parallel arrays (2 String and 2 double). My text file needs to look something like this:
    John Johnson
    0000004738294961
    502.67
    1000.000
    Jane Smith
    0000005296847913
    284.51
    1000.000
    ...and so on
    Where the first thing is the name (obviously), an account number, the balance in the account, and the credit limit. I just cant figure out how to read everything into the arrays. We havent learned anything too heavy, and this seems a little too advanced for my class, but I guess we will manage. Any help will be appreciated. Thanks guys.
    Casey

    Man this is a dumb homework assignment. The requirements scream out for a class along the lines of
    public class Account{
      private String name, number;
      private double balance,creditlimit;
       // more code here
    }and then to use a List of Account objects.
    Anyway what's your actual problem. There's nothing very hard about it. A loop. So....
    You should consider posting (formatted) code showing what you have done and where exactly you are stuck.

  • Index array is not getting new values from DAQ

    I am measuring force values with my DAQ card and these values are always changing.  However, in my programming something is not working right with the way I have things set up.  After my DAQ I have a "Convert to Dynamic Data" and after that I have an "Index Array".  When the program is executing and I turn on the highlight option I do not get changing force values after the "Convert to Dynamic Data" and therefore no changing force values enter my "Index Array".  Whaterever the first value is that gets passed to the "Convert to Dynamic Data" is the only value that I get for the remainder of the program.  I tried plugging in an indicator between the DAQ and the "Convert to Dynamic Data" and it did show varying values.  Please help with my program.  I have tried messing with the properties of the "Convert to Dynamic Data" and nothing has worked.  I am stuck and cannot see how to fix this problem.  I have attached my program as it is currently put together.
    Thank You In Advance,
    Gabe.
    Attachments:
    Actuator_Gabe_Oct27_Flat_Sequence_XY_+Measurement_File.vi ‏131 KB

    Please know that the best option is to review the concepts discussed to further understand programming in LabVIEW.  Perhaps you could take a look through ni.com/gettingstarted and ni.com/lv101 to have a look at some of the online help materials.  I have included a VI snippet of the while loop containing the changes.  Further, the code you attached contains a lot of customer controls and VIs, which are not common to all LabVIEW users.  It is a best practice to only attach the code of value to the question/post, and to have the most simplified version of the problem.
    Best,
    Adam
    Academic Product Manager
    National Intruments

  • How do i impliment this array

    Hey everyone, just came across this forum looks quite good so I'll give it a go smile.gif
    Just working through a book called 'Objects First with Java' and I'm stuck on exercise 4.31.
    This is about a small auction program that has 4 classes - auction, bid, lot and person.
    Here's the code:
    Auction:
    import java.util.ArrayList;
    import java.util.Iterator;
    * A simple model of an auction.
    * The auction maintains a list of lots of arbitrary length.
    * @author David J. Barnes and Michael Kolling.
    * @version 2008.03.30
    public class Auction
        // The list of Lots in this auction.
        private ArrayList<Lot> lots;
        // The number that will be given to the next lot entered
        // into this auction.
        private int nextLotNumber;
        private Lot selectedLot;
         * Create a new auction.
        public Auction()
            lots = new ArrayList<Lot>();
            nextLotNumber = 1;
         * Enter a new lot into the auction.
         * @param description A description of the lot.
        public void enterLot(String description)
            lots.add(new Lot(nextLotNumber, description));
            nextLotNumber++;
         * Show the full list of lots in this auction.
        public void showLots()
            for(Lot lot : lots) {
                System.out.println(lot.toString());
         * Bid for a lot.
         * A message indicating whether the bid is successful or not
         * is printed.
         * @param number The lot number being bid for.
         * @param bidder The person bidding for the lot.
         * @param value  The value of the bid.
        public void bidFor(int lotNumber, Person bidder, long value)
            selectedLot = getLot(lotNumber);
            if(selectedLot != null) {
                boolean successful = selectedLot.bidFor(new Bid(bidder, value));
                if(successful) {
                    System.out.println("The bid for lot number " +
                                       lotNumber + " was successful.");
                else {
                    // Report which bid is higher.
                    Bid highestBid = selectedLot.getHighestBid();
                    System.out.println("Lot number: " + lotNumber +
                                       " already has a bid of: " +
                                       highestBid.getValue());
         * Return the lot with the given number. Return null
         * if a lot with this number does not exist.
         * @param lotNumber The number of the lot to return.
        public Lot getLot(int lotNumber){
            if((lotNumber >= 1) && (lotNumber < nextLotNumber)) {
                // The number seems to be reasonable.
                Lot selectedLot = lots.get(lotNumber - 1);
                // Include a confidence check to be sure we have the
                // right lot.
                if(selectedLot.getNumber() != lotNumber) {
                    System.out.println("Internal error: Lot number " +
                                       selectedLot.getNumber() +
                                       " was returned instead of " +
                                       lotNumber);
                    // Don't return an invalid lot.
                    selectedLot = null;
                return selectedLot;
            else {
                System.out.println("Lot number: " + lotNumber +
                                   " does not exist.");
                return null;
        public void close() {
            for(Lot lot : lots){
                Bid highestBid=lot.getHighestBid();
                Person person=highestBid.getBidder();
                String personName=person.getName();
                String number = "" + lot.getNumber();
                if(lot.getHighestBid() == null) {
                    System.out.println(number + ": " + lot.getDescription()+" has *not* been sold");
                else {
                    System.out.println(lot.getDescription()+" has been sold to " );
        // Creates a new array list and stores all unsold items into notSold.
        // Returns all items in the new list.
       /* public ArrayList<Lot> getUnsold;
            ArrayList<String> notSold;
            Integer numberList = 1;
            notSold = new ArrayList<String>(); // Creates new array
            for(Lot lot : lots){ // Although it compiles, when I create an auction object
                                 // it returns 'null pointer exception' here, any suggestions?
                if(lot.getHighestBid() == null)
                    notSold.add(lot.getDescription());
                    for(String unsold : notSold){
                        System.out.println(numberList + ": " + unsold);
                        System.out.println();
                        numberList++;
    }        There are a few random things in there, just from me mucking around in other exercises.
    Lot:
    * A class to model an item (or set of items) in an
    * auction: a lot.
    * @author David J. Barnes and Michael Kolling.
    * @version 2008.03.30
    public class Lot
        // A unique identifying number.
        private final int number;
        // A description of the lot.
        private String description;
        // The current highest bid for this lot.
        private Bid highestBid;
         * Construct a Lot, setting its number and description.
         * @param number The lot number.
         * @param description A description of this lot.
        public Lot(int number, String description)
            this.number = number;
            this.description = description;
         * Attempt to bid for this lot. A successful bid
         * must have a value higher than any existing bid.
         * @param bid A new bid.
         * @return true if successful, false otherwise
        public boolean bidFor(Bid bid)
            if((highestBid == null) ||
                   (bid.getValue() > highestBid.getValue())) {
                // This bid is the best so far.
                highestBid = bid;
                return true;
            else {
                return false;
         * @return A string representation of this lot's details.
        public String toString()
            String details = number + ": " + description;
            if(highestBid != null) {
                details += "    Bid: " +
                           highestBid.getValue();
            else {
                details += "    (No bid)";
            return details;
         * @return The lot's number.
        public int getNumber()
            return number;
         * @return The lot's description.
        public String getDescription()
            return description;
         * @return The highest bid for this lot.
         *         This could be null if there is
         *         no current bid.
        public Bid getHighestBid()
            return highestBid;
    }Bid:
    * A class that models an auction bid.
    * It contains a reference to the Person bidding and the amount bid.
    * @author David J. Barnes and Michael Kolling.
    * @version 2008.03.30
    public class Bid
        // The person making the bid.
        private final Person bidder;
        // The value of the bid. This could be a large number so
        // the long type has been used.
        private final long value;
         * Create a bid.
         * @param bidder Who is bidding for the lot.
         * @param value The value of the bid.
        public Bid(Person bidder, long value)
            this.bidder = bidder;
            this.value = value;
         * @return The bidder.
        public Person getBidder()
            return bidder;
         * @return The value of the bid.
        public long getValue()
            return value;
    }Person:
    public class Person
        // The name of this person.
        private final String name;
         * Create a new person with the given name.
         * @param name The person's name.
        public Person(String name)
            this.name = name;
         * @return The person's name.
        public String getName()
            return name;
    }Question: Rewrite getLot so that it does not rely on a lot with a particular number being stored at index (number-1) in the collection. For instance, if lot number 2 has been removed, then lot number 3 will have been moved from index 2 to index 1, and all higher lot numbers will also have been moved by one index position. You may assume that lots are always stored in increasing order of their lot number.
    So I know it's talking about an arraylist but I can't think how to implement it, I have tried a number of ways but can't seem to get my head round it. After I couldn't work out how to rewrite just the getLot I started spreading out and trying to add new arraylists in different classes and calling them but it ultimately just failed so now I was just wanting to get some ideas from people.

    @ The OP....
    Word of advice. Posting pages of code that are provided for YOU are not gonna be welcome on these forums. You can however take snippets of code and post them here and in turn ask a more precise question. For example....
    I modified this method..
    *post code
    and get the following error in compiler
    *post error                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Memory Question - Help!

    I just started trying to import footage from a camera to my Mac. While my laptop doesn't have a ton of spare memory, I have an external hard drive that does. Question: how can I set iMovie HD 6 to use the connected external hard drive's memory rather

  • 11gR2 RAC installation in AIX fails while running root.sh on node2

    Hi We are in the process on installing 11gR2 RAC on AIX 6.1 But the installation is failing on node 2while running root.sh with the following error. DiskGroup DATA creation failed with the following message: ORA-15018: diskgroup cannot be created ORA

  • How to replace the desktop case tower

    I recently bought a refurbished ENVY 700 series desktop computer, it's in great condition. Unfortunately, I accidently dropped it and cracked the front cover of the case tower. I love the case design, but I don't want to have a cracked case in the re

  • I pod 5th gen please help

    I put my app store  code in, but when I tried buying an app it kept on leading me to the credit card information. How do I get the app without using a credit card?

  • NEW CERTIFICATION: OCP -  Oracle Fusion Middleware 11g Forms Developer

    Oracle Certification announces the release of the new "Oracle Certified Professional, Oracle Fusion Middleware 11g Forms Developer" certification. This certification is for- (READ MORE) http://bit.ly/wGGFut