Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

Create a class called Cards
public class Cards{
public int number; // 1-Ace... 11-, 12 Queen, 13-King
public int type; 1-4 is each type

public void createCard(int number, int type);
public static int drawCard();
public static void shuffle();

public static void main(String[] args){
Cards deck = new Cards[52];
int k=0;
for(int i=0;i<4;i++){
for(int j = 0;j<13;j++){
deck[k++].create(j,i);
}
}
Cards.shuffle();

}

- Anonymous January 10, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

could you please code the functions
public void createCard(int number, int type);
public static int drawCard();
public static void shuffle();

- anonymous May 14, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

and also what would happen if i draw the card 53 times.....

Thanks

- anonymous May 14, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

add another one:
Cards.distribute(ArrayList playerList, GameRule rule);

Player class, GameRule class.

- Anonymous March 14, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

One class for cards, which accepts Suit and Rank of the card. It should have a constructor that accepts Suit and Rank, and a copy ctor, assignment operator. That is a minimal interface for a card.

Now, another class that contains a vector of cards. I would have a static int in there for the number of cards (54?). Add construct/dtor functions. Add a reset function to sort the cards to their original order. Add a function that accepts a number and deals the topmost cards of the deck. It should remove them from the deck. Add another function to shuffle the cards... And the list goes on.

- Anonymous May 24, 2009 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More