Amazon Interview Question for Software Engineer / Developers


Team: AFT
Country: United States
Interview Type: In-Person




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

Putting only classes and interfaces:

typedef long ID;

enum Roll {CASHIER, MANAGER, WAITER};
class Employee
{
	ID empID;
	string name;
	Roll roll;
	public:
	setRoll ();
}

class Waiter: public Employee
{
	public:
	waiter() {	setRoll (WAITOR); }
}

class Cashier: public Employee
{
	public:
	cashier () {	setRoll (CASHIER); }
}

class Table
{
	ID tableId;
	bool isAvailable;
	int capacity;
	int used;

	public:
	Table(ID id) {tableId = id; // set other params also}

	bool isAvailable ();
	void reserveTable ();
	void freeTable ();
}

Class Item
{
	ID itemID;
	double itemCost;
	public:
	getItemCost ();
}

class Order
{
	Table tableID;
	Waiter waiterID;
	Cashier cashierID;

	vector<item, int> request; // item, quantity
	public:
	void placeOrder (itemID, quantity) ;// push_back in request vector
	double getBill (); // call Invoice Class's generateBill()
}

class Menu
{
	map<item, double> itemCostMap; //
	map<item, int> itermQuantityMap; //

	public:
	double getItemCost (Item itemID);
	int getItemQuantity (Item itemID);
	bool isItemAvailable (Item itemID);
}

class invoice
{
	Menu menu;
	public:
	generateBill (vector<itemID, quantity>); // uses Menu class getItemCost () to get cost and generate bill
}


class coffeeShop
{
	List<Table> tables;
	List<Waiter> waiters;
	List<Cashier> cashiers;
	map<Table, Order> orders;

	public:
	coffeeShop ()
	{
		//initialise each table with ID and capacity; and other member also;
	}
	void addWaiter ();
	void removeWaiter ();
	void addCashier();
	void removeCashier ();
	//similar for other employees, like manager 

	void addTable ();
	void removeTable():

	void getOrder (Table tableId, Item itemID, int quantity); // this will order object and place in map

	double getBill (Table tableId)
	{ 
		Order order = orders[tableId]; 
		order.getBill ();
	}
}

- SK January 31, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

I think ..it's solution should "Decorator Design pattern"

- Ajit February 02, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Decorator may be good for coffee machine. I think managing coffee shop is different problem.

- Harsh May 18, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is there any further clarification about the questions? Design a sales system, hr system or ...?

- baoyiweii1 February 02, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For Coffee -- Use Decorator.
For Coffee Shops -- Use Builder as multiple shops needs to be opened.

- fearless Coder July 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

This problem is addressed in the book "Head First Design Patterns", and the solutions uses de Decorator Pattern.

- Fernando April 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Coffee machine and shop are different aspects. Book speaks about writing algo for coffee machine.

In fact, you may relate it to the pizza store example given for abstract factory pattern.

- Harsh May 18, 2014 | 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