Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

#include <iostream>
#include <list>
using namespace std;

class CareTaker
{
    private:
    public:
       virtual void PrintDetails() = 0;
};

class IndividualCareTaker : public CareTaker
{
    string sCareTakerName_;
    int iAge_;
    public:
        void PrintDetails();
};

class GroupCareTaker
{
    list<IndividualCareTaker*> lCareTakers_;
    public:
        void PrintDetails()
        {
        }
};

enum ECageType
{
    CAGE_METAL,
    CAGE_WOOD
};

class Cage
{
    private:
        ECageType eType_;
};

class FlyingType
{
    public:
        virtual void Fly() = 0;
};

class CanFly : public FlyingType
{
    public:
        void Fly()
        {
            cout << "Can Fly" << endl;
        }
};

class CannotFly : public FlyingType
{
    public:
        void Fly()
        {
            cout << "Can not Fly" << endl;
        }
};

class Animal
{
    private:
        Cage* pCageForAnimal_;
        CareTaker* pAnimalCareTaker_;
        string sAnimalName_;
    public:
        const Cage* GetItsCage();
        const CareTaker* GetItsCareTaker();
        const string& GetItsName();
        virtual void PrintItsDetails() = 0;
};

class Birds : public Animal
{
    private:
        FlyingType* pItsFlyingType;
    public:
        bool SetFlyingType(FlyingType* flyingType);
        void PrintItsDetails();

};

class Mammals : public Animal
{
    private:
        int iNumberOfLegs_;
        bool bDangerous_;
    public:
        void PrintItsDetails();
};

class Zoo
{
    private:
        list<Animal*> lAnimalList_;
    public:
        void DisplayAllAnimals();
        void GetCountOfAnimals();
};

- Pankaj Kumar January 24, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Different behaviors of animals like walkable, flyable can be interface which can allow you define/implement behaviors for different animals.

- aniruddh.ranjekar January 24, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

This is not a Zoo game you are designing for,
you have to design a zoo management system for real world purpose.
So, you dot need to make your animals fly and eat, for e.g. you cannot make a lion in the zoo eat by calling lion.eat() method. You could do so, if you designed it for a game

- sumanth August 24, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Strategy design pattern

- highway January 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
#include <list>
using namespace std;

class CareTaker
{
private:
public:
virtual void PrintDetails() = 0;
};

class IndividualCareTaker : public CareTaker
{
string sCareTakerName_;
int iAge_;
public:
void PrintDetails();
};

class GroupCareTaker
{
list<IndividualCareTaker*> lCareTakers_;
public:
void PrintDetails()
{
}
};

enum ECageType
{
CAGE_METAL,
CAGE_WOOD
};

class Cage
{
private:
ECageType eType_;
};

class FlyingType
{
public:
virtual void Fly() = 0;
};

class CanFly : public FlyingType
{
public:
void Fly()
{
cout << "Can Fly" << endl;
}
};

class CannotFly : public FlyingType
{
public:
void Fly()
{
cout << "Can not Fly" << endl;
}
};

class Animal
{
private:
Cage* pCageForAnimal_;
CareTaker* pAnimalCareTaker_;
string sAnimalName_;
public:
const Cage* GetItsCage();
const CareTaker* GetItsCareTaker();
const string& GetItsName();
virtual void PrintItsDetails() = 0;
};

class Birds : public Animal
{
private:
FlyingType* pItsFlyingType;
public:
bool SetFlyingType(FlyingType* flyingType);
void PrintItsDetails();

};

class Mammals : public Animal
{
private:
int iNumberOfLegs_;
bool bDangerous_;
public:
void PrintItsDetails();
};

class Zoo
{
private:
list<Animal*> lAnimalList_;
public:
void DisplayAllAnimals();
void GetCountOfAnimals();
};

- Anonymous September 15, 2023 | 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