Need help with a Java programming project

Discussion in 'OT Technology' started by unknown_soldier, Dec 9, 2004.

  1. I have to create a program where a chessboard object exists. The first square has 1 piece of rice on it, the 2nd square doubles the first, the 3rd square doubles the 2nd, etc.

    Square - 1 - 1.0
    Square - 2 - 2.0
    Square - 3 - 4.0
    Square - 4 - 8.0
    Square - 5 - 16.0
    etc. etc.
    I have to use the Math.pow method
    and the chessboard object must be a separate class.

    Is anybody able to give me some direction with this? I'm also not sure about the chessboard object being a separate class. :hs:
     
  2. korrupshun

    korrupshun New Member

    Joined:
    Sep 8, 2004
    Messages:
    389
    Likes Received:
    0
    Location:
    YourMommasHouse
    should be rather easy...

    pseudo:

    chessboard{

    private places[][];

    constructor(){...}
    putRice(how many grains, location){...} //location is probably a tuple (ie. pair of indices)

    }

    //separate file (tho not necessary)

    Runner{

    pub stat void main(...){
    while(not last space){
    place grains in space //since this is where the bulk of the logic is, im
    //intentionally leaving it vague, hint: mathematical
    //expression for grains of rice per square is a constant
    // math.pow formula

    increase indices


    }
    }//

    }

    EDIT: forgot closing brace :mamoru:
     

Share This Page