Do you accept the challenge?
language = java
goal = efficiency
challenge: Write a shuffling method for a vectored list of card objects. The cards start in order (Ace of Spades, ..., 2 of Spades, Hearts, Diamonds, Clubs). Here is the method prototype:
public void shuffle() {}
-----------------------------------------------------------
Sidenote: Yes, I am trying to get you to do my programming for me because I''m too lazy. So there!!!
"When i was a child I caught a fleeting glimpse, out ofthe corner of my mind. I turned to look, but it was gone, I cannot put my finger on it now. The child hasgrown, the dream has gone." -Pink Floyd
Edited by - farmersckn on November 10, 2000 2:53:03 PM
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
// Make an array to hold the shuffled deck.
// Make an int to hold the index of the unshuffled deck,
// from which you will take cards, and insert into the shuffled
// deck.
// for loop, 0 to 52
// 1 get card from unshuffled deck, at loop index.
// 2 get a random index into the shuffled deck.
// 3 if the cell in the shuffled deck at the random index
// is empty, then insert the card.
// 4 else, goto 2
// end for loop
I think that''s all.
This, however, is not the place to ask people to do your homework. Nobody likes that. Also, it will severely hamper your ability to program, as you will grow dependent upon us here at gamedev, and you will actually be a sucky programmer! so don''t do it again!
farmersckn
// Make an int to hold the index of the unshuffled deck,
// from which you will take cards, and insert into the shuffled
// deck.
// for loop, 0 to 52
// 1 get card from unshuffled deck, at loop index.
// 2 get a random index into the shuffled deck.
// 3 if the cell in the shuffled deck at the random index
// is empty, then insert the card.
// 4 else, goto 2
// end for loop
I think that''s all.
This, however, is not the place to ask people to do your homework. Nobody likes that. Also, it will severely hamper your ability to program, as you will grow dependent upon us here at gamedev, and you will actually be a sucky programmer! so don''t do it again!
farmersckn
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
I wouldn''t normally have done that. I was just kinda fried that day and didn''t really feel like thinking. Don''t worry, I know how annoying dependance can be. I''m suprised someone replied.
Anyway, don''t worry, it won''t happen again. It''s not nearly as fun to leasrn this way anyway.
Anyway, don''t worry, it won''t happen again. It''s not nearly as fun to leasrn this way anyway.
"When i was a child I caught a fleeting glimpse, out ofthe corner of my mind. I turned to look, but it was gone, I cannot put my finger on it now. The child hasgrown, the dream has gone." -Pink Floyd
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement