Regards,<br />Jigar Gosar (SCJP 1.4)<br />visit: <a href="http://jigar.org/blog" target="_blank" rel="nofollow">http://jigar.org/blog</a>
Smita Raval
Regards,<br />Jigar Gosar (SCJP 1.4)<br />visit: <a href="http://jigar.org/blog" target="_blank" rel="nofollow">http://jigar.org/blog</a>
Originally posted by Jigar Gosarr:
Possiblity 1nly chessboard has two dimentional array and stores reference to chesspiece in it and null value if there is no chesspiece present on that particular chess square(ie. arr[i][j]).
Arguments:
1.disadvantage:A lot of space will be wasted since there will be many null values.
3.disadvantage:it will be very difficult and time consuming process to query that given a chesspiece object, where it lies on chess board.We will have iterate all chess squares inquring wheather that i,j square contains the given chesspiece.
Possiblity 2
nly each chesspiece contains the info as to where it belongs on chessboard. this info is maintained in its private variable "int x,y".
Argument:
1.disadvantage:it is possible that two chesspiece might ,by mistake, contain same x,y values this leads to inconsistancy since no two chesspiece can be on same chess square.
3.disadvantage:in order to find which chesspiece is present on given i,j square we will have to query all chesspiece and ask them wheather they are currently belonging to i,j square this is time consuming since there are 10000 chesspiece in this imaginary chess board.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus