Amazon Interview Question for Software Engineer / Developers






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

//techdive.in/java/card-game-using-java

public class CARD implements Comparable<CARD>
{
        private CARD()
        {
        }

        public enum CARDNUMBER
        {
                TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(8), NINE(9), TEN(10), JACK(11), QUEEN(12), KING(13), ACE(
                                14);

                private int     ord;

                private CARDNUMBER(int i)
                {
                        this.ord = i;
                }

                /**
                 * Returns the ordinal position of the enum
                 * 
                 * @return int ord
                 */
                public int getOrd()
                {
                        return ord;
                }
        }

        public enum CARDTYPE
        {
                CLUB, DIAMOND, HEARTS, SPADE;
        }

        private CARDNUMBER      cdNumber;
        private CARDTYPE        cdType;

        public CARDNUMBER getCdNumber()
        {
                return cdNumber;
        }

        public CARDTYPE getCdType()
        {
                return cdType;
        }

        public static List<CARD> getPackOfCards()
        {
                List<CARD> crdLst = new ArrayList<CARD>();

                for (CARDTYPE types : CARDTYPE.values())
                {
                        for (CARDNUMBER cNums : CARDNUMBER.values())
                        {
                                CARD cd = new CARD();
                                cd.cdNumber = cNums;
                                cd.cdType = types;
                                crdLst.add(cd);
                        }
                }
                return crdLst;
        }

        public static void shuffleCards(List<CARD> cards)
        {
                Collections.shuffle(cards);
        }

        @Override
        public int compareTo(CARD o)
        {
                if (this.getCdNumber() == o.getCdNumber())
                {
                        return 0;
                }
                else if (this.getCdNumber().getOrd() > o.getCdNumber().getOrd())
                {
                        return 1;
                }
                else
                        return -1;
        }

        @Override
        public String toString()
        {
                return "CARD [cdNumber=" + cdNumber + ", cdType=" + cdType + "]";
        }
}

- Rocket Raja January 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can refer cracking the code interview book to get a solution for this.

- Anon September 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

anybody please tell how to practice such types of designing questions in c++.Any link would be of great help

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

Refer to Head First Design Patterns. It has quite a few worked out examples that will help you clear out your design concepts.

- DesignJunky September 05, 2012 | Flag


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